# Service

Defines a named Effect service whose value is a `Push`.

The returned class exposes `onSuccess`, `onFailure`, and `run` as Effects that
first resolve the service from Context. `make` captures the Sink construction
context and combines it with each output subscriber's context; it does not start
the Fx or send an input while building the Layer.

## Signatures

```ts
export declare function Service<Self, A, E = never, B = never, E2 = never>(): <const Id extends string>(id: Id) => Push.Class<Self, Id, A, E, B, E2>;
```

## Why

A service gives a bidirectional application capability one stable identity, so
producers and observers can depend on it through ordinary Effect requirements.

## Ownership and lifetime

The returned Layer owns service installation and captures non-Scope services
needed by both sides. Output runs retain the caller's Scope and interruption;
input acknowledgment Effects run in their caller. Layer release drops the
service but does not invent cleanup beyond the supplied Sink and Fx.

## Examples

```ts
import { Effect, Layer } from "effect"
import * as Fx from "@typed/fx/Fx"
import * as Push from "@typed/fx/Push"
import * as Sink from "@typed/fx/Sink"

class Messages extends Push.Service<Messages, string, never, string>()("Messages") {}
const MessagesLive = Messages.make(
  Sink.make(() => Effect.void, (message) => Effect.log(message)),
  Fx.succeed("ready")
)
const send = Messages.onSuccess("hello").pipe(Effect.provide(MessagesLive))
```
