def server.prepared

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

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

1139def server.prepared(~A: Data, ~S: Type, ~K: Data, ~H: Data,
1140  ~work: S -> Application<A, K, Policy<H>> -> BufferedRequest -> IO(S & Result<&2, &2, Unit, ApplicationReport<H>>),
1141  ~destroy: S -> IO(Unit), app: Application<A, K, Policy<H>>, +config: Http.ServerConfig, resources: List<S> & Nat
1142) -> IO(Result<&2, &1, StartupError, Server<A, S, K, H>>):
1143  Http.ServerConfig{host, port, body, headers, connections, requests, +buffered, hm, bm, im, wm} = config
1144  (bundles, capacity) = resources
1145  match capacity:
1146    case 0n:
1147      do IO<Result<&2, &1, StartupError, Server<A, S, K, H>>>:
1148        dispose(~S, ~destroy, bundles)
1149        return Fail{EmptyBundles{}}
1150    case 1n+ +rest:
1151      do IO<Result<&2, &1, StartupError, Server<A, S, K, H>>>:
1152        messages : Chan(Message<S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>>) <-
1153          Chan.new(Message<S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>>, buffered)
1154        +context : Context<S, Application<A, K, Policy<H>>, BufferedRequest, Unit, ApplicationReport<H>> = Context{messages}
1155        started : List<S> & Result<&2, &1, Http.StartupError, Http.Server<ServingContext<A, S, K, H>>> <-
1156          Http.server.start(~ServingContext<A, S, K, H>, ~List<S>, ServingContext{app, context}, bundles, config)
1157        server.started(~A, ~S, ~K, ~H, ~work, ~destroy, context, buffered, 1n+rest, started)

Uses (26)

Used by (1)