> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.nvidia.com/holoscan/sdk-user-guide/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.nvidia.com/holoscan/sdk-user-guide/_mcp/server.

# holoscan::DistributedAppService

> Composite service interface for distributed fragment services.

Composite service interface for distributed fragment services.

`DistributedAppService` combines the [FragmentService](fragmentservice) interface with distributed endpoint capabilities, allowing a single service implementation to:

* Manage shared resources within a fragment ([FragmentService](fragmentservice))
* Act as a driver coordinator in distributed applications (ServiceDriverEndpoint)
* Act as a worker participant in distributed applications (ServiceWorkerEndpoint)

This composite interface is particularly useful for services that need to synchronize state or coordinate operations across multiple fragments in a distributed Holoscan application. When registered with the application using `register_service()`, the framework automatically calls the appropriate driver/worker methods based on each fragment's role.

```cpp showLineNumbers={false}
#include <holoscan/fragment_service.hpp>
```

In single-fragment applications, only the [FragmentService](fragmentservice) interface is used. The distributed endpoint methods are only called in multi-fragment distributed applications.

**Inherits from:** `holoscan::FragmentService` (public), `holoscan::distributed::ServiceDriverEndpoint` (public), `holoscan::distributed::ServiceWorkerEndpoint` (public)

---

## Methods

### FragmentService \[#fragmentservice]

```cpp showLineNumbers={false}
holoscan::FragmentService::FragmentService() = default
```

Inherit constructors from base classes.

This using declaration enables construction of `DistributedAppService` using the constructors of [FragmentService](fragmentservice), ServiceDriverEndpoint, and ServiceWorkerEndpoint, providing flexibility in how derived classes can be initialized.

### resource \[#resource]

#### Mutable

```cpp showLineNumbers={false}
virtual void holoscan::DistributedAppService::resource(
    const std::shared_ptr<Resource> &resource
)
```

Set the underlying resource managed by this service.

**Parameters**

**`resource`** `const std::shared_ptr<Resource> &`

Shared pointer to the resource to be managed.

---

#### Const

const

```cpp showLineNumbers={false}
virtual std::shared_ptr<Resource> holoscan::DistributedAppService::resource() const
```

Get the underlying resource managed by this service.

**Returns:** Shared pointer to the managed resource.

### driver\_start \[#driverstart]

```cpp showLineNumbers={false}
virtual void holoscan::DistributedAppService::driver_start(
    std::string_view driver_ip
)
```

Start the driver endpoint for distributed coordination.

This method is called by the framework on the driver fragment when the distributed application starts. Implementations should initialize any necessary resources for coordinating with worker fragments.

**Parameters**

**`driver_ip`** `std::string_view`

The IP address of the driver fragment.

---

### driver\_shutdown \[#drivershutdown]

```cpp showLineNumbers={false}
virtual void holoscan::DistributedAppService::driver_shutdown()
```

Shutdown the driver endpoint.

This method is called by the framework when the distributed application is shutting down. Implementations should clean up resources and notify any connected workers of the shutdown.

### worker\_connect \[#workerconnect]

```cpp showLineNumbers={false}
virtual void holoscan::DistributedAppService::worker_connect(
    std::string_view driver_ip
)
```

Connect the worker endpoint to the driver.

This method is called by the framework on worker fragments to establish a connection with the driver fragment. Implementations should connect to the driver and prepare to participate in distributed operations.

**Parameters**

**`driver_ip`** `std::string_view`

The IP address of the driver fragment to connect to.

---

### worker\_disconnect \[#workerdisconnect]

```cpp showLineNumbers={false}
virtual void holoscan::DistributedAppService::worker_disconnect()
```

Disconnect the worker endpoint from the driver.

This method is called by the framework when the worker needs to disconnect from the driver. Implementations should clean up the connection and any associated resources.