HEX
Server: LiteSpeed
System: Linux sg-cp4.cloudnetwork.vn 4.18.0-553.69.1.lve.el8.x86_64 #1 SMP Wed Aug 13 19:53:59 UTC 2025 x86_64
User: thu28850 (1134)
PHP: 7.4.33
Disabled: NONE
Upload Files
File: //opt/imunify360/venv/lib64/python3.11/site-packages/nats/micro/__init__.py
# Copyright 2021-2022 The NATS Authors
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

from dataclasses import replace
from typing import Optional

from nats.aio.client import Client

from .request import Handler, Request
from .service import Service, ServiceConfig


async def add_service(nc: Client, config: Optional[ServiceConfig] = None, **kwargs) -> Service:
    """Add a service."""
    if config:
        config = replace(config, **kwargs)
    else:
        config = ServiceConfig(**kwargs)

    service = Service(nc, config)
    await service.start()

    return service


__all__ = ["add_service"]