Skip to main content Link Search Menu Expand Document (external link)

MessageRouter overview

Added in v0.1.0


Table of contents


constructors

empty

Signature

export declare const empty: MessageRouter<never, never>

Added in v0.1.0

fromIterable

Signature

export declare const fromIterable: <R extends Route<any, any>>(
  routes: Iterable<R>
) => MessageRouter<R extends Route<infer E, infer _> ? E : never, R extends Route<infer _, infer Env> ? Env : never>

Added in v0.1.0

makeRoute

Signature

export declare const makeRoute: <E, R>(
  topic: Route.Path,
  handler: Route.Handler<E, R>
) => Route<E, MessageRouter.ExcludeProvided<R>>

Added in v0.1.0

models

Default (type alias)

Signature

export type Default<E = never, R = never> = Effect.Effect<void, E, R | ConsumerRecord.ConsumerRecord>

Added in v0.1.0

MessageRouter (interface)

Signature

export interface MessageRouter<E = never, R = never> extends Default<E, R>, Inspectable.Inspectable {
  readonly [TypeId]: TypeId
  readonly routes: Chunk.Chunk<Route<E, R>>
}

Added in v0.1.0

Route (interface)

Signature

export interface Route<E = never, R = never> {
  readonly [RouteTypeId]: RouteTypeId
  readonly topic: Route.Path
  readonly handler: Route.Handler<E, R>
}

Added in v0.1.0

routing

subscribe

Signature

export declare const subscribe: {
  <E1, R1>(
    topic: Route.Path,
    handler: Route.Handler<E1, R1>
  ): <E, R>(self: MessageRouter<E, R>) => MessageRouter<E1 | E, R | MessageRouter.ExcludeProvided<R1>>
  <E, R, E1, R1>(
    self: MessageRouter<E, R>,
    topic: Route.Path,
    handler: Route.Handler<E1, R1>
  ): MessageRouter<E | E1, R | MessageRouter.ExcludeProvided<R1>>
}

Added in v0.1.0

type ids

RouteTypeId

Signature

export declare const RouteTypeId: typeof RouteTypeId

Added in v0.1.0

RouteTypeId (type alias)

Signature

export type RouteTypeId = typeof RouteTypeId

Added in v0.1.0

TypeId

Signature

export declare const TypeId: typeof TypeId

Added in v0.1.0

TypeId (type alias)

Signature

export type TypeId = typeof TypeId

Added in v0.1.0

utils

MessageRouter (namespace)

Added in v0.1.0

Service (interface)

Signature

export interface Service<E, R> {
  readonly router: Effect.Effect<MessageRouter<E, R>>
  readonly addRoute: (route: Route<E, R>) => Effect.Effect<void>
  readonly subscribe: (path: Route.Path, handler: Route.Handler<E, R | Provided>) => Effect.Effect<void>
  readonly concat: (router: MessageRouter<E, R>) => Effect.Effect<void>
}

Added in v0.1.0

TagClass (interface)

Signature

export interface TagClass<Self, Name extends string, E, R> extends Context.Tag<Self, Service<E, R>> {
  readonly Live: Layer.Layer<Self>
  readonly router: Effect.Effect<MessageRouter<E, R>, never, Self>
  // readonly use: <XA, XE, XR>(
  //   f: (router: Service<E, R>) => Effect.Effect<XA, XE, XR>,
  // ) => Layer.Layer<never, XE, XR>;
  // readonly useScoped: <XA, XE, XR>(
  //   f: (router: Service<E, R>) => Effect.Effect<XA, XE, XR>,
  // ) => Layer.Layer<never, XE, Exclude<XR, Scope.Scope>>;
  readonly unwrap: <XA, XE, XR>(f: (router: MessageRouter<E, R>) => Layer.Layer<XA, XE, XR>) => Layer.Layer<XA, XE, XR>
  new (_: never): Context.TagClassShape<Name, Service<E, R>>
}

Added in v0.1.0

ExcludeProvided (type alias)

Signature

export type ExcludeProvided<A> = Exclude<A, Provided>

Added in v0.1.0

Provided (type alias)

Signature

export type Provided = ConsumerRecord.ConsumerRecord | Scope.Scope

Added in v0.1.0

Route (namespace)

Added in v0.1.0

Handler (type alias)

Signature

export type Handler<E, R> = Default<E, R>

Added in v0.1.0

Path (type alias)

Signature

export type Path = string | RegExp

Added in v0.2.0