MCPcopy Create free account
hub / github.com/effect-app/libs / toChannelMap

Function toChannelMap

repos/effect/packages/effect/src/unstable/socket/Socket.ts:386–435  ·  view source on GitHub ↗
(
  self: Socket,
  f: (data: Uint8Array | string) => A
)

Source from the content-addressed store, hash-verified

384 * Typed error for an unsupported or failed in-place TLS upgrade.
385 *
386 * @category errors
387 * @since 4.0.0
388 */
389export class SocketUpgradeError extends Schema.Error<SocketUpgradeError>(
390 "effect/socket/Socket/SocketUpgradeError"
391)({
392 _tag: Schema.tag("SocketUpgradeError"),
393 cause: Schema.optional(Schema.Defect())
394}) {
395 /**
396 * An upgrade implementation for transports that cannot wrap the connection
397 * with TLS.
398 *
399 * @since 4.0.0
400 */
401 static readonly unsupported: Reader["upgrade"] = () =>
402 Effect.fail(new SocketError({ reason: new SocketUpgradeError({}) }))
403
404 override get message() {
405 return this.cause === undefined
406 ? `Socket does not support TLS upgrade`
407 : `An error occurred during TLS upgrade`
408 }
409}
410
411/**
412 * Typed error for a socket close, carrying the close code and optional close
413 * reason.
414 *
415 * **Details**
416 *
417 * Sockets never classify closes: any close, whatever the code, fails the
418 * reader with a `SocketError` wrapping this reason. Consumers that treat a
419 * close as normal catch it.
420 *
421 * @category errors
422 * @since 4.0.0
423 */
424export class SocketCloseError extends Schema.Error<SocketCloseError>("effect/socket/Socket/SocketCloseError")({
425 _tag: Schema.tag("SocketCloseError"),
426 code: Schema.Int,
427 closeReason: Schema.optional(Schema.String)
428}) {
429 override get message() {
430 if (this.closeReason) {
431 return `${this.code}: ${this.closeReason}`
432 }
433 return `${this.code}`
434 }
435}
436
437/**
438 * Schema for all socket-specific error reasons.

Callers 2

toChannelFunction · 0.85
Socket.tsFile · 0.85

Calls 9

closeMethod · 0.80
offerUnsafeMethod · 0.80
writeFunction · 0.70
makeMethod · 0.65
pipeMethod · 0.65
takeAllMethod · 0.65
fFunction · 0.50
provideMethod · 0.45
runRawMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…