blob: 81dd62a3ccd5f4a28d057d21d1fec64bf3aefb55 [file] [log] [blame] [view]
# Services
A service provides a set of [FIDL][FIDL] [protocols][protocol] over a
[channel].
## Instances
Multiple named instances of a service can be hosted by a single component.
If no instance name is provided, the default instance name `default` is used.
A component can also access multiple instances in its incoming namespace.
These are presented in the incoming namespace as subdirectories of the service.
For example, the Netstack service with instance `default` would be accessible
at the path `/svc/fuchsia.netstack.Netstack/default`.
## Protocols
A service is a grouping of named FIDL [protocols][protocol].
Logically-related protocols can be aggregated into a service and routed as a
single unit.
An example of a FIDL service definition:
```fidl
service Netstack {
fuchsia.net.NameLookup name_lookup;
fuchsia.posix.socket.Provider socket_provider;
}
```
Each protocol has a name and is accessible as a subdirectory of the service
instance. For example, the `socket_provider` protocol of the Netstack service
instance `default` is accessible at the path
`/svc/fuchsia.netstack.Netstack/default/socket_provider`.
Note: If the instance name and protocol are known ahead of time, it is possible
to open the protocol directly with zero round-trips.
## Routing
Services are routed to other Components through
[service capabilities][service-capability].
[channel]: /docs/glossary.md#channel
[FIDL]: /docs/glossary.md#fidl
[namespace]: /docs/glossary.md#namespace
[protocol]: /docs/glossary.md#protocol
[service-capability]: /docs/concepts/components/capabilities/service.md