inmemory

package
v1.0.0-beta4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 1, 2026 License: Apache-2.0 Imports: 26 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

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

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

GetEntity returns an entity's metadata. An entity exists while it has state.

func (*Server) GetInstance

GetInstance returns an instance's current state.

func (*Server) GetWorkItems

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) Hello

Hello implements the service handshake.

func (*Server) ListInstanceIds

ListInstanceIds returns IDs of terminal instances, ordered by completion time.

func (*Server) PurgeInstances

PurgeInstances deletes terminal instances and, optionally, their sub-orchestrations.

func (*Server) QueryEntities

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

QueryInstances returns instances that match a query, ordered by creation time.

func (*Server) RaiseEvent

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

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

RewindInstance enqueues recovery of a failed instance through the worker.

func (*Server) SignalEntity

SignalEntity sends a one-way operation to an entity.

func (*Server) StartInstance

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL