MCPcopy
hub / github.com/Effect-TS/effect / makeExecute

Function makeExecute

packages/sql/src/SqlResolver.ts:121–158  ·  view source on GitHub ↗
(self: RequestResolver.RequestResolver<SqlRequest<T, A, E>>)

Source from the content-addressed store, hash-verified

119 function make(context: Context.Context<R> | undefined) {
120 const encode = Schema.encode(Request)
121 function makeExecute(self: RequestResolver.RequestResolver<SqlRequest<T, A, E>>) {
122 return function(input: I) {
123 return Effect.useSpan(
124 `sql.Resolver.execute ${tag}`,
125 { kind: "client", captureStackTrace: false },
126 (span) =>
127 Effect.withFiberRuntime<A, E | ParseError, RI>((fiber) => {
128 span.attribute("request.input", input)
129 const currentContext = fiber.currentContext
130 const connection = currentContext.unsafeMap.get(
131 internalClient.TransactionConnection.key
132 )
133 let toProvide: Context.Context<R> | undefined = context
134 if (connection !== undefined) {
135 if (toProvide === undefined) {
136 toProvide = Context.make(
137 internalClient.TransactionConnection,
138 connection
139 ) as Context.Context<R>
140 } else {
141 toProvide = Context.add(
142 toProvide,
143 internalClient.TransactionConnection,
144 connection
145 )
146 }
147 }
148 const resolver = toProvide === undefined
149 ? self
150 : RequestResolver.provideContext(self, toProvide)
151 return Effect.flatMap(
152 encode(input),
153 (encoded) => Effect.request(makeRequest<T, I, II, A, E>(tag, input, encoded, span), resolver)
154 )
155 })
156 )
157 }
158 }
159 return Object.assign(self, {
160 request(input: I) {
161 return Effect.withFiberRuntime<SqlRequest<T, A, E>, ParseError, RI>(

Callers 2

makeFunction · 0.85
makeFunction · 0.85

Calls 7

requestMethod · 0.80
encodeFunction · 0.70
makeRequestFunction · 0.70
attributeMethod · 0.65
getMethod · 0.65
makeMethod · 0.65
addMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…