Skip to content

Commit

Permalink
fix: allows methods to support all options
Browse files Browse the repository at this point in the history
  • Loading branch information
cludden committed Apr 18, 2023
1 parent 74d1c70 commit f0b828c
Show file tree
Hide file tree
Showing 7 changed files with 279 additions and 278 deletions.
6 changes: 3 additions & 3 deletions example/mutex.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (wf *MutexWorkflow) Execute(ctx workflow.Context) error {

log.Info("notifying lease holder")
info := workflow.GetInfo(ctx)
if err := mutexv1.LeaseAcquiredExternal(ctx, lease.GetWorkflowId(), "", &mutexv1.LeaseAcquiredSignal{
if err := mutexv1.LeaseAcquiredExternal(ctx, lease.GetWorkflowId(), "", &mutexv1.LeaseAcquiredRequest{
WorkflowId: info.WorkflowExecution.ID,
RunId: info.WorkflowExecution.RunID,
LeaseId: leaseID,
Expand Down Expand Up @@ -117,7 +117,7 @@ func (wf *SampleWorkflowWithMutexWorkflow) Execute(ctx workflow.Context) (resp *
defer func() {
wf.log.Info("revoking lease", "lease", lease.GetLeaseId())
cancelCtx, _ := workflow.NewDisconnectedContext(ctx)
if mutexv1.RevokeLeaseExternal(cancelCtx, lease.GetWorkflowId(), lease.GetRunId(), &mutexv1.RevokeLeaseSignal{
if mutexv1.RevokeLeaseExternal(cancelCtx, lease.GetWorkflowId(), lease.GetRunId(), &mutexv1.RevokeLeaseRequest{
LeaseId: lease.GetLeaseId(),
}).Get(ctx, nil); err != nil {
wf.log.Error("error revoking lease", "error", err, "lease", lease.GetLeaseId())
Expand All @@ -139,7 +139,7 @@ type Activites struct {

// Mutex locks a shared resource and can be called from a parent workflow
func (a *Activites) Mutex(ctx context.Context, req *mutexv1.MutexRequest) error {
_, err := a.Client.StartMutexWithAcquireLease(ctx, nil, req, &mutexv1.AcquireLeaseSignal{
_, err := a.Client.StartMutexWithAcquireLease(ctx, nil, req, &mutexv1.AcquireLeaseRequest{
WorkflowId: activity.GetInfo(ctx).WorkflowExecution.ID,
Timeout: durationpb.New(time.Minute * 2),
})
Expand Down
269 changes: 135 additions & 134 deletions example/mutexv1/example.pb.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions example/mutexv1/example.proto
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,22 @@ service Mutex {
// ##########################################################################

// AcquireLease enqueues a lease on the given resource
rpc AcquireLease(AcquireLeaseSignal) returns (google.protobuf.Empty) {
rpc AcquireLease(AcquireLeaseRequest) returns (google.protobuf.Empty) {
option (temporal.v1.signal) = {};
}

// LeaseAcquired enqueues a lease on the given resource
rpc LeaseAcquired(LeaseAcquiredSignal) returns (google.protobuf.Empty) {
rpc LeaseAcquired(LeaseAcquiredRequest) returns (google.protobuf.Empty) {
option (temporal.v1.signal) = {};
}

// RenewLease enqueues a lease on the given resource
rpc RenewLease(RenewLeaseSignal) returns (google.protobuf.Empty) {
rpc RenewLease(RenewLeaseRequest) returns (google.protobuf.Empty) {
option (temporal.v1.signal) = {};
}

// RevokeLease enqueues a lease on the given resource
rpc RevokeLease(RevokeLeaseSignal) returns (google.protobuf.Empty) {
rpc RevokeLease(RevokeLeaseRequest) returns (google.protobuf.Empty) {
option (temporal.v1.signal) = {};
}
}
Expand All @@ -91,22 +91,22 @@ message SampleWorkflowWithMutexResponse {
// Signal Messages
// ############################################################################

message AcquireLeaseSignal {
message AcquireLeaseRequest {
string workflow_id = 1;
google.protobuf.Duration timeout = 2;
}

message LeaseAcquiredSignal {
message LeaseAcquiredRequest {
string workflow_id = 1;
string run_id = 2;
string lease_id = 3;
}

message RenewLeaseSignal {
message RenewLeaseRequest {
string lease_id = 1;
google.protobuf.Duration timeout = 2;
}

message RevokeLeaseSignal {
message RevokeLeaseRequest {
string lease_id = 1;
}
Loading

0 comments on commit f0b828c

Please sign in to comment.