@@ -43,7 +43,9 @@ import (
4343 invokev1 "github.com/dapr/dapr/pkg/messaging/v1"
4444 internalsv1pb "github.com/dapr/dapr/pkg/proto/internals/v1"
4545 "github.com/dapr/dapr/pkg/resiliency"
46+ "github.com/dapr/dapr/pkg/runtime/compstore"
4647 "github.com/dapr/dapr/pkg/runtime/wfengine/state"
48+ "github.com/dapr/dapr/pkg/runtime/wfengine/state/list"
4749 "github.com/dapr/dapr/pkg/runtime/wfengine/todo"
4850 "github.com/dapr/dapr/utils"
4951 "github.com/dapr/durabletask-go/api"
@@ -62,15 +64,15 @@ const (
6264 WorkflowNameLabelKey = "workflow"
6365 ActivityNameLabelKey = "activity"
6466 ExecutorNameLabelKey = "executor"
65- ActorTypePrefix = "dapr.internal."
6667)
6768
6869type Options struct {
69- AppID string
70- Namespace string
71- Actors actors.Interface
72- Resiliency resiliency.Provider
73- EventSink orchestrator.EventSink
70+ AppID string
71+ Namespace string
72+ Actors actors.Interface
73+ Resiliency resiliency.Provider
74+ EventSink orchestrator.EventSink
75+ ComponentStore * compstore.ComponentStore
7476 // experimental feature
7577 // enabling this will use the cluster tasks backend for pending tasks, instead of the default local implementation
7678 // the cluster tasks backend uses actors to share the state of pending tasks
@@ -90,6 +92,7 @@ type Actors struct {
9092 resiliency resiliency.Provider
9193 actors actors.Interface
9294 eventSink orchestrator.EventSink
95+ compStore * compstore.ComponentStore
9396
9497 orchestrationWorkItemChan chan * backend.OrchestrationWorkItem
9598 activityWorkItemChan chan * backend.ActivityWorkItem
@@ -102,19 +105,20 @@ func New(opts Options) *Actors {
102105 if opts .EnableClusteredDeployment {
103106 pendingTasksBackend = NewClusterTasksBackend (ClusterTasksBackendOptions {
104107 Actors : opts .Actors ,
105- ExecutorActorType : ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ExecutorNameLabelKey ,
108+ ExecutorActorType : todo . ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ExecutorNameLabelKey ,
106109 })
107110 }
108111 return & Actors {
109112 appID : opts .AppID ,
110113 namespace : opts .Namespace ,
111- workflowActorType : ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + WorkflowNameLabelKey ,
112- activityActorType : ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ActivityNameLabelKey ,
113- executorActorType : ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ExecutorNameLabelKey ,
114+ workflowActorType : todo . ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + WorkflowNameLabelKey ,
115+ activityActorType : todo . ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ActivityNameLabelKey ,
116+ executorActorType : todo . ActorTypePrefix + opts .Namespace + utils .DotDelimiter + opts .AppID + utils .DotDelimiter + ExecutorNameLabelKey ,
114117 actors : opts .Actors ,
115118 resiliency : opts .Resiliency ,
116119 pendingTasksBackend : pendingTasksBackend ,
117120 enableClusteredDeployment : opts .EnableClusteredDeployment ,
121+ compStore : opts .ComponentStore ,
118122 orchestrationWorkItemChan : make (chan * backend.OrchestrationWorkItem , 1 ),
119123 activityWorkItemChan : make (chan * backend.ActivityWorkItem , 1 ),
120124 eventSink : opts .EventSink ,
@@ -630,6 +634,42 @@ func (abe *Actors) WaitForOrchestratorCompletion(ctx context.Context, request *p
630634 return abe .pendingTasksBackend .WaitForOrchestratorCompletion (ctx , request )
631635}
632636
637+ func (abe * Actors ) ListInstanceIDs (ctx context.Context , req * protos.ListInstanceIDsRequest ) (* protos.ListInstanceIDsResponse , error ) {
638+ resp , err := list .ListInstanceIDs (ctx , list.ListOptions {
639+ ComponentStore : abe .compStore ,
640+ Namespace : abe .namespace ,
641+ AppID : abe .appID ,
642+ PageSize : req .PageSize , //nolint:protogetter
643+ ContinuationToken : req .ContinuationToken , //nolint:protogetter
644+ })
645+ if err != nil {
646+ return nil , err
647+ }
648+
649+ return & protos.ListInstanceIDsResponse {
650+ InstanceIds : resp .Keys ,
651+ ContinuationToken : resp .ContinuationToken ,
652+ }, nil
653+ }
654+
655+ func (abe * Actors ) GetInstanceHistory (ctx context.Context , req * protos.GetInstanceHistoryRequest ) (* protos.GetInstanceHistoryResponse , error ) {
656+ ss , err := abe .actors .State (ctx )
657+ if err != nil {
658+ return nil , err
659+ }
660+
661+ resp , err := state .LoadWorkflowState (ctx , ss , req .GetInstanceId (), state.Options {
662+ AppID : abe .appID ,
663+ WorkflowActorType : abe .workflowActorType ,
664+ ActivityActorType : abe .activityActorType ,
665+ })
666+ if err != nil {
667+ return nil , err
668+ }
669+
670+ return & protos.GetInstanceHistoryResponse {Events : resp .History }, nil
671+ }
672+
633673func (abe * Actors ) purgeWorkflow (ctx context.Context , id api.InstanceID ) error {
634674 req := internalsv1pb .
635675 NewInternalInvokeRequest (todo .PurgeWorkflowStateMethod ).
@@ -702,11 +742,3 @@ func (abe *Actors) purgeWorkflowForce(ctx context.Context, id api.InstanceID) er
702742 },
703743 )
704744}
705-
706- func (abe * Actors ) GetInstanceHistory (ctx context.Context , req * protos.GetInstanceHistoryRequest ) (* protos.GetInstanceHistoryResponse , error ) {
707- return nil , status .Error (codes .Unimplemented , "GetInstanceHistory is not implemented in the Actors backend" )
708- }
709-
710- func (abe * Actors ) ListInstanceIDs (ctx context.Context , req * protos.ListInstanceIDsRequest ) (* protos.ListInstanceIDsResponse , error ) {
711- return nil , status .Error (codes .Unimplemented , "ListInstanceIDs is not implemented in the Actors backend" )
712- }
0 commit comments