def server.started

bend-kit-camber@0.15.0.1 · camber.bend:1118

import bend-kit-camber@0.15.0.1/camber.bend as Camber
import Base
import bend-kit-http@0.38.1.1/http.bend as Http

1118def server.started(~A: Data, ~S: Type, ~K: Data, ~H: Data,
1119  ~work: S -> Application<A, K, Policy<H>> -> BufferedRequest -> IO(S & Result<&2, &2, Unit, ApplicationReport<H>>),
1120  ~destroy: S -> IO(Unit),
1121  +context: Context<S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>>,
1122  room: U32, capacity: Nat,
1123  started: List<S> & Result<&2, &1, Http.StartupError, Http.Server<ServingContext<A, S, K, H>>>
1124) -> IO(Result<&2, &1, StartupError, Server<A, S, K, H>>):
1125  Context{+messages} = context
1126  (resources, result) = started
1127  match result:
1128    case Fail{error}:
1129      do IO<Result<&2, &1, StartupError, Server<A, S, K, H>>>:
1130        dispose(~S, ~destroy, resources)
1131        Chan.close(Message<S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>>, messages)
1132        return Fail{TransportFailed{error}}
1133    case Done{transport}:
1134      do IO<Result<&2, &1, StartupError, Server<A, S, K, H>>>:
1135        finished : Chan(Unit) <- IO.fork(Unit, owner(~S, ~Application<A, K, Policy<H>>, ~BufferedRequest, ~Unit, ~ApplicationReport<H>,
1136          ~work, ~destroy, messages, room, Waiting{resources, ledger.open(capacity)}))
1137        return Done{Server{transport, Owner{Context{messages}, finished}}}

Uses (29)

Used by (1)