HEX
Server: LiteSpeed
System: Linux cpir1.prohostdns.com 4.18.0-553.123.2.lve.el8.x86_64 #1 SMP Thu May 7 23:17:13 UTC 2026 x86_64
User: pelakir (2976)
PHP: 8.2.31
Disabled: exec, shell_exec, system, passthru, proc_open, proc_close, proc_terminate, proc_get_status, popen, pclose, pcntl_exec
Upload Files
File: //opt/imunify360/venv/lib/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"]