Chat unstable
The routed outbound chat service.
Chat has the ops of every registered adapter and routes each call by the
address's platform. Chat.layer provides the router and an empty
ChatAdapter.Registry; adapter layers stack on top with
Layer.provideMerge, and a platform that is off is a layer left out.
Example Posting through the router
import { Effect } from "effect"import { Chat, ChatThread } from "effect/chat"
const program = Effect.gen(function*() { const chat = yield* Chat.Chat const posted = yield* chat.post(ChatThread.make("slack", "T1/C1"), { markdown: "Hello" }) return posted.id})Combinators
withoutRetries
unstable Since v4.1.5 Source
Runs an effect with adapter retries turned off, so every adapter call inside it makes one attempt.
Gotchas
The name is provisional.
Signature
declare function withoutRetries<A, E, R>(effect: Effect<A, E, R>): Effect<A, E, R>Layers
Services
Service that routes chat operations to the adapter registered for each address's platform.
Details
- Every op takes an address and goes to the adapter for
thread.platform, failing withNoAdapterwhen there is none. getUsertakes the platform first, because a bare user id names none.followUpis routed by the platform of the deferred command's thread. One call per deferral is the portable contract: the first is the answer, and a second is platform-specific, a new message on Slack (up to five) and an overwrite of the first on Discord. It is rendered asrespondis, so it never mentions anyone: Slack shows the token as text and Discord renders it and notifies nobody.descriptorreturns a platform's capabilities and limits.- Each call runs in a
Chat.{op}span whose attributes are the platform, the op and, on failure, the error reason and retry value.
Signature
declare class Chat extends Shape<"effect/chat/Chat", Omit<Ops, "getUser"> & { readonly descriptor: (platform: string) => Effect<Descriptor, ChatError>; readonly getUser: (platform: string, id: string, options?: { readonly in?: { readonly id: string; readonly platform: string; }; }) => Effect<User, ChatError>;}, this> { constructor(_: never);}