Files
scriptc/tests/fixtures/effect4/cluster-entity.ts
Chris Tate e2d58f60d2 Expand static support for common Effect 4 patterns (#600)
* Expand static compilation for common Effect 4 patterns

* Run every Effect 4 fixture slice in CI

* Preserve existing corpus behavior across Effect 4 lowering

* Preserve Effect platform callbacks and native stream state

* Record new corpus baselines and retain child stdin refusals

* Retire the obsolete stateful regex diagnostic

* Preserve promise reference count layout for cycle collection
2026-10-01 17:36:29 -05:00

9 lines
855 B
TypeScript

import * as Effect from "effect/Effect"
import * as Layer from "effect/Layer"
import * as Ref from "effect/Ref"
import * as Schema from "effect/Schema"
import * as Entity from "effect/cluster/Entity"
import * as TestRunner from "effect/cluster/TestRunner"
import * as Rpc from "effect/rpc/Rpc"
const C=Entity.make("Counter",[Rpc.make("Inc",{payload:{amount:Schema.Int},success:Schema.Int})]);const handlers=C.toLayer(Effect.gen(function*(){const n=yield* Ref.make(0);return C.of({Inc:({payload})=>Ref.updateAndGet(n,v=>v+payload.amount)})}));Effect.runPromise((Effect.gen(function*(){const client=yield* C.client;const c=client("counter-1");return [yield* c.Inc({amount:1}),yield* c.Inc({amount:2})]}).pipe(Effect.provide(handlers.pipe(Layer.provideMerge(TestRunner.layer))))).pipe(Effect.tap(value=>Effect.sync(()=>console.log(JSON.stringify(value))))))