{"modulePath":"github.com/microsoft/durabletask-go","version":"v1.0.0-beta4","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package durabletasktest\n\nPackage durabletasktest runs orchestrations, activities, and entities in process for tests.\n\nA [Host](#Host) starts an in-memory Durable Task service, a worker for the orchestrators, activities, and entities in a [task.TaskRegistry](/github.com/microsoft/durabletask-go/task#TaskRegistry), and a client connected to the same service. Communication uses an in-memory gRPC transport, so no network ports or external services are required.\n\n\tregistry := task.NewTaskRegistry()\n\tregistry.AddOrchestratorN(\"Greeting\", greeting)\n\tregistry.AddActivityN(\"SayHello\", sayHello)\n\n\thost := durabletasktest.New(t, registry)\n\tid, err := host.Client().ScheduleNewOrchestration(ctx, \"Greeting\")\n\t...\n\tmetadata, err := host.Client().WaitForOrchestrationCompletion(ctx, id)\n\nOrchestrations run through the same worker, executor, and client code paths that production workers use. To isolate an orchestrator from external dependencies, register stub activities in the test's registry.\n\nTimers use the Go runtime clock. Tests can use testing/synctest to advance timers without waiting in real time. Failed orchestrations can be rewound with the same history-safety limitations as the production worker. Rewind enqueues recovery and preserves successful work; outstanding timers and activities are recovered. Activities can run again if their results are unavailable. Purged children without retained results are recreated without their previous history; conflicting child IDs prevent rewind. Histories without a committed execution start cannot be rewound. Durable entities are supported, including entity critical sections: signals and calls to a locked entity from outside its critical section wait until the lock is released. An entity operation is dispatched in a work item with the entity's state, so an operation's input and the entity's state must fit together in a 4 MiB work item. SignalEntity returns an error wrapping [api.ErrInvalidArgument](/github.com/microsoft/durabletask-go/api#ErrInvalidArgument) if a signal doesn't fit with the entity's current state. Calls that don't fit when they are dispatched fail; signals are dropped, and the host logs a warning, which [New](#New) also reports with [testing.TB.Log](/testing#TB.Log). An entity batch whose result exceeds 4 MiB isn't applied, and its calls fail with the non-retriable error type EntityResultTooLarge. Entity query pages contain at most 100 entries and 64 MiB of serialized data; follow the continuation token to retrieve the remaining entities.\n\n## Types\n\n```go\ntype Host struct {\n\t// contains filtered or unexported fields\n}\n```\nHost is an in-process Durable Task service with a running worker and a client.\n\n```go\nfunc New(tb testing.TB, registry *task.TaskRegistry, opts ...Option) *Host\n```\nNew starts a [Host](#Host) for a test and closes it when the test and its subtests finish. It stops the test with [testing.TB.Fatal](/testing#TB.Fatal) if the host can't start. The host also reports entity signals that the service drops with [testing.TB.Log](/testing#TB.Log).\n\n```go\nfunc NewHost(ctx context.Context, registry *task.TaskRegistry, opts ...Option) (*Host, error)\n```\nNewHost starts an in-memory service and a worker for the registry. Call [Host.Close](#Host.Close) to stop it. ctx bounds startup only.\n\n```go\nfunc (h *Host) Client() *client.TaskHubGrpcClient\n```\nClient returns a client connected to the host's in-memory service.\n\n```go\nfunc (h *Host) Close(ctx context.Context) error\n```\nClose stops the worker and the in-memory service. All orchestration state is discarded. If ctx ends before in-flight work items finish, they are canceled.\n\n```go\ntype Option func(*options)\n```\nOption configures a [Host](#Host).\n\n```go\nfunc WithClientOptions(opts ...client.TaskHubGrpcClientOption) Option\n```\nWithClientOptions adds options for the host's client, such as a data converter.\n\n```go\nfunc WithLogger(logger api.Logger) Option\n```\nWithLogger sets the logger used by the worker, client, and in-memory service. The service logs a warning when it drops an entity signal. By default, the host discards log output.\n\n```go\nfunc WithWorkerOptions(opts ...client.TaskHubGrpcWorkerOption) Option\n```\nWithWorkerOptions adds options for the host's worker, such as a data converter or versioning settings.\n\n","path":"github.com/microsoft/durabletask-go/durabletasktest","name":"durabletasktest","synopsis":"Package durabletasktest runs orchestrations, activities, and entities in process for tests.","isRedistributable":true}
