Documentation
¶
Overview ¶
Package inmemory implements an in-memory Durable Task sidecar service for tests.
The service keeps all orchestration state in process memory and serves the same gRPC protocol as the Durable Task Scheduler, so the regular client and worker can run against it, including durable entities and rewind. Timers fire in real time.
Index ¶
- func ServerOptions() []grpc.ServerOption
- type Server
- func (s *Server) AbandonTaskActivityWorkItem(_ context.Context, req *protos.AbandonActivityTaskRequest) (*protos.AbandonActivityTaskResponse, error)
- func (s *Server) AbandonTaskEntityWorkItem(_ context.Context, req *protos.AbandonEntityTaskRequest) (*protos.AbandonEntityTaskResponse, error)
- func (s *Server) AbandonTaskOrchestratorWorkItem(_ context.Context, req *protos.AbandonOrchestrationTaskRequest) (*protos.AbandonOrchestrationTaskResponse, error)
- func (s *Server) CleanEntityStorage(_ context.Context, req *protos.CleanEntityStorageRequest) (*protos.CleanEntityStorageResponse, error)
- func (s *Server) Close()
- func (s *Server) CompleteActivityTask(_ context.Context, resp *protos.ActivityResponse) (*protos.CompleteTaskResponse, error)
- func (s *Server) CompleteEntityTask(_ context.Context, result *protos.EntityBatchResult) (*protos.CompleteTaskResponse, error)
- func (s *Server) CompleteOrchestratorTask(_ context.Context, resp *protos.OrchestratorResponse) (*protos.CompleteTaskResponse, error)
- func (s *Server) GetEntity(_ context.Context, req *protos.GetEntityRequest) (*protos.GetEntityResponse, error)
- func (s *Server) GetInstance(_ context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
- func (s *Server) GetWorkItems(req *protos.GetWorkItemsRequest, ...) error
- func (s *Server) Hello(context.Context, *emptypb.Empty) (*emptypb.Empty, error)
- func (s *Server) ListInstanceIds(_ context.Context, req *protos.ListInstanceIdsRequest) (*protos.ListInstanceIdsResponse, error)
- func (s *Server) PurgeInstances(_ context.Context, req *protos.PurgeInstancesRequest) (*protos.PurgeInstancesResponse, error)
- func (s *Server) QueryEntities(_ context.Context, req *protos.QueryEntitiesRequest) (*protos.QueryEntitiesResponse, error)
- func (s *Server) QueryInstances(_ context.Context, req *protos.QueryInstancesRequest) (*protos.QueryInstancesResponse, error)
- func (s *Server) RaiseEvent(_ context.Context, req *protos.RaiseEventRequest) (*protos.RaiseEventResponse, error)
- func (s *Server) Register(registrar grpc.ServiceRegistrar)
- func (s *Server) RestartInstance(_ context.Context, req *protos.RestartInstanceRequest) (*protos.RestartInstanceResponse, error)
- func (s *Server) ResumeInstance(_ context.Context, req *protos.ResumeRequest) (*protos.ResumeResponse, error)
- func (s *Server) RewindInstance(_ context.Context, req *protos.RewindInstanceRequest) (*protos.RewindInstanceResponse, error)
- func (s *Server) SignalEntity(_ context.Context, req *protos.SignalEntityRequest) (*protos.SignalEntityResponse, error)
- func (s *Server) StartInstance(_ context.Context, req *protos.CreateInstanceRequest) (*protos.CreateInstanceResponse, error)
- func (s *Server) StreamInstanceHistory(req *protos.StreamInstanceHistoryRequest, ...) error
- func (s *Server) SuspendInstance(_ context.Context, req *protos.SuspendRequest) (*protos.SuspendResponse, error)
- func (s *Server) TerminateInstance(_ context.Context, req *protos.TerminateRequest) (*protos.TerminateResponse, error)
- func (s *Server) WaitForInstanceCompletion(ctx context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
- func (s *Server) WaitForInstanceStart(ctx context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
- type ServerOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServerOptions ¶
func ServerOptions() []grpc.ServerOption
ServerOptions returns the gRPC server options for the service. The transport accepts large messages so that oversized completions reach the service, which enforces the 4 MiB request limit itself.
Types ¶
type Server ¶
type Server struct {
protos.UnimplementedTaskHubSidecarServiceServer
// contains filtered or unexported fields
}
Server is an in-memory implementation of the TaskHubSidecarService.
func NewServer ¶
func NewServer(opts ...ServerOption) *Server
NewServer creates an empty in-memory service.
func (*Server) AbandonTaskActivityWorkItem ¶
func (s *Server) AbandonTaskActivityWorkItem( _ context.Context, req *protos.AbandonActivityTaskRequest, ) (*protos.AbandonActivityTaskResponse, error)
AbandonTaskActivityWorkItem returns an activity work item to the queue.
func (*Server) AbandonTaskEntityWorkItem ¶
func (s *Server) AbandonTaskEntityWorkItem( _ context.Context, req *protos.AbandonEntityTaskRequest, ) (*protos.AbandonEntityTaskResponse, error)
AbandonTaskEntityWorkItem returns an entity work item's operations to the entity's queue.
func (*Server) AbandonTaskOrchestratorWorkItem ¶
func (s *Server) AbandonTaskOrchestratorWorkItem( _ context.Context, req *protos.AbandonOrchestrationTaskRequest, ) (*protos.AbandonOrchestrationTaskResponse, error)
AbandonTaskOrchestratorWorkItem returns an orchestration work item to the queue.
func (*Server) CleanEntityStorage ¶
func (s *Server) CleanEntityStorage(_ context.Context, req *protos.CleanEntityStorageRequest) (*protos.CleanEntityStorageResponse, error)
CleanEntityStorage releases locks held by orchestrations that are no longer running and removes entities that have no state, messages, or lock.
func (*Server) Close ¶
func (s *Server) Close()
Close stops timers and ends all open work item streams and waiters.
func (*Server) CompleteActivityTask ¶
func (s *Server) CompleteActivityTask(_ context.Context, resp *protos.ActivityResponse) (*protos.CompleteTaskResponse, error)
CompleteActivityTask records an activity result in its orchestration's inbox.
func (*Server) CompleteEntityTask ¶
func (s *Server) CompleteEntityTask(_ context.Context, result *protos.EntityBatchResult) (*protos.CompleteTaskResponse, error)
CompleteEntityTask commits an entity batch: it stores the new state, sends results to calling orchestrations, and applies the batch's actions. A batch result larger than the message limit isn't applied; its calls fail with EntityResultTooLarge instead.
func (*Server) CompleteOrchestratorTask ¶
func (s *Server) CompleteOrchestratorTask(_ context.Context, resp *protos.OrchestratorResponse) (*protos.CompleteTaskResponse, error)
CompleteOrchestratorTask commits an orchestration turn and applies its actions.
func (*Server) GetEntity ¶
func (s *Server) GetEntity(_ context.Context, req *protos.GetEntityRequest) (*protos.GetEntityResponse, error)
GetEntity returns an entity's metadata. An entity exists while it has state.
func (*Server) GetInstance ¶
func (s *Server) GetInstance(_ context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
GetInstance returns an instance's current state.
func (*Server) GetWorkItems ¶
func (s *Server) GetWorkItems(req *protos.GetWorkItemsRequest, stream grpc.ServerStreamingServer[protos.WorkItem]) error
GetWorkItems streams orchestration, activity, and entity work items to a worker. Work items that are still in flight when the stream ends are returned to the queue.
func (*Server) ListInstanceIds ¶
func (s *Server) ListInstanceIds(_ context.Context, req *protos.ListInstanceIdsRequest) (*protos.ListInstanceIdsResponse, error)
ListInstanceIds returns IDs of terminal instances, ordered by completion time.
func (*Server) PurgeInstances ¶
func (s *Server) PurgeInstances(_ context.Context, req *protos.PurgeInstancesRequest) (*protos.PurgeInstancesResponse, error)
PurgeInstances deletes terminal instances and, optionally, their sub-orchestrations.
func (*Server) QueryEntities ¶
func (s *Server) QueryEntities(_ context.Context, req *protos.QueryEntitiesRequest) (*protos.QueryEntitiesResponse, error)
QueryEntities returns entities that match a query, ordered by instance ID. The continuation token encodes the last returned instance ID, so a query resumes after it even if entities are added or removed between pages. Pages contain at most defaultQueryPageSize entries and 64 MiB of serialized data.
func (*Server) QueryInstances ¶
func (s *Server) QueryInstances(_ context.Context, req *protos.QueryInstancesRequest) (*protos.QueryInstancesResponse, error)
QueryInstances returns instances that match a query, ordered by creation time.
func (*Server) RaiseEvent ¶
func (s *Server) RaiseEvent(_ context.Context, req *protos.RaiseEventRequest) (*protos.RaiseEventResponse, error)
RaiseEvent delivers an external event to an instance.
func (*Server) Register ¶
func (s *Server) Register(registrar grpc.ServiceRegistrar)
Register registers the service with a gRPC server.
func (*Server) RestartInstance ¶
func (s *Server) RestartInstance(_ context.Context, req *protos.RestartInstanceRequest) (*protos.RestartInstanceResponse, error)
RestartInstance starts a terminal instance again with its original input.
func (*Server) ResumeInstance ¶
func (s *Server) ResumeInstance(_ context.Context, req *protos.ResumeRequest) (*protos.ResumeResponse, error)
ResumeInstance resumes a suspended instance.
func (*Server) RewindInstance ¶
func (s *Server) RewindInstance(_ context.Context, req *protos.RewindInstanceRequest) (*protos.RewindInstanceResponse, error)
RewindInstance enqueues recovery of a failed instance through the worker.
func (*Server) SignalEntity ¶
func (s *Server) SignalEntity(_ context.Context, req *protos.SignalEntityRequest) (*protos.SignalEntityResponse, error)
SignalEntity sends a one-way operation to an entity.
func (*Server) StartInstance ¶
func (s *Server) StartInstance(_ context.Context, req *protos.CreateInstanceRequest) (*protos.CreateInstanceResponse, error)
StartInstance creates a new orchestration instance.
func (*Server) StreamInstanceHistory ¶
func (s *Server) StreamInstanceHistory( req *protos.StreamInstanceHistoryRequest, stream grpc.ServerStreamingServer[protos.HistoryChunk], ) error
StreamInstanceHistory streams an instance's committed history.
func (*Server) SuspendInstance ¶
func (s *Server) SuspendInstance(_ context.Context, req *protos.SuspendRequest) (*protos.SuspendResponse, error)
SuspendInstance suspends a running instance.
func (*Server) TerminateInstance ¶
func (s *Server) TerminateInstance(_ context.Context, req *protos.TerminateRequest) (*protos.TerminateResponse, error)
TerminateInstance terminates an instance and, optionally, its sub-orchestrations.
func (*Server) WaitForInstanceCompletion ¶
func (s *Server) WaitForInstanceCompletion(ctx context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
WaitForInstanceCompletion blocks until the instance reaches a terminal state.
func (*Server) WaitForInstanceStart ¶
func (s *Server) WaitForInstanceStart(ctx context.Context, req *protos.GetInstanceRequest) (*protos.GetInstanceResponse, error)
WaitForInstanceStart blocks until the instance starts running or ends.
type ServerOption ¶
type ServerOption func(*Server)
ServerOption configures a Server.
func WithDroppedSignalReporter ¶
func WithDroppedSignalReporter(report func(message string)) ServerOption
WithDroppedSignalReporter sets a function that also receives the warning for each entity signal that the service drops. The service calls it with its lock held and not after the service is closed.
func WithLogger ¶
func WithLogger(logger api.Logger) ServerOption
WithLogger sets the logger the service uses to report messages that it drops. By default, the service discards log output.