This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cadence --domain tavern workflow run --tl greetings --wt programmingpercy/cadence-tavern/workflows/greetings.workflowGreetings --et 60 -i '{"name": "Percy"}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cadence --domain tavern workflow run --tl greetings --wt programmingpercy/cadence-tavern/workflows/greetings.workflowGreetings --et 60 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Running execution: | |
Workflow Id : 21e30ae8-8246-412d-a6d2-cc0782cf66d4 | |
Run Id : 7c3514b4-6839-43ee-9d45-d9d54c7c9a44 | |
Type : programmingpercy/cadence-tavern/workflows/greetings.workflowGreetings | |
Domain : tavern | |
Task List : greetings | |
Args : | |
Progress: | |
1, 2022-02-28T20:27:25+01:00, WorkflowExecutionStarted | |
2, 2022-02-28T20:27:25+01:00, DecisionTaskScheduled |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
percy@tavern: go run main.go | |
2022-02-28T20:12:23.215+0100 INFO internal/internal_worker.go:834 Started Workflow Worker {"Domain": "tavern", "TaskList": "greetings", "WorkerID": "10484@DESKTOP-3DP516F@greetings@b2156771-c3f8-4e3e-845f-375b1f58081a"} | |
2022-02-28T20:12:23.239+0100 INFO internal/internal_worker.go:859 Started Activity Worker {"Domain": "tavern", "TaskList": "greetings", "WorkerID": "10484@DESKTOP-3DP516F@greetings@b2156771-c3f8-4e3e-845f-375b1f58081a"} | |
2022-02-28T20:12:23.239+0100 INFO app/main.go:44 Started Worker. {"worker": "greetings"} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
// Here we Import the Package, which will make Register Kick in | |
_ "programmingpercy/cadence-tavern/workflows/greetings" | |
_ "go.uber.org/cadence/.gen/go/cadence" | |
"go.uber.org/cadence/.gen/go/cadence/workflowserviceclient" | |
"go.uber.org/cadence/worker" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package greetings | |
import ( | |
"context" | |
"programmingpercy/cadence-tavern/customer" | |
"time" | |
"go.uber.org/cadence/activity" | |
"go.uber.org/cadence/workflow" | |
"go.uber.org/zap" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func init() { | |
// init will be called once the workflow file is imported | |
// this will Register the workflow to the Worker service | |
workflow.Register(workflowGreetings) | |
// Register the activities also | |
activity.Register(activityGreetings) | |
activity.Register(activityStoreCustomer) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// activityGreetings is used to say Hello to a Customer and change their LastVisit and TimesVisisted | |
// The returned value will be a Customer struct filled with this information | |
func activityGreetings(ctx context.Context, visitor customer.Customer) (customer.Customer, error) { | |
logger := activity.GetLogger(ctx) | |
logger.Info("Greetings activity started") | |
logger.Info("New Visitor", zap.String("customer", visitor.Name), zap.Int("visitorCount", visitorCount)) | |
visitorCount++ | |
oldCustomerInfo, _ := customer.Database.Get(visitor.Name) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// workflowGreetings is the Workflow that is used to handle new Customers in the Tavern. | |
// our Workflow accepts a customer as Input, and Outputs a Customer, and an Error | |
func workflowGreetings(ctx workflow.Context, visitor customer.Customer) (customer.Customer, error) { | |
// workflow Options for HeartBeat Timeout and other Timeouts. | |
ao := workflow.ActivityOptions{ | |
ScheduleToStartTimeout: time.Minute, | |
StartToCloseTimeout: time.Minute, | |
HeartbeatTimeout: time.Second * 20, | |
// Here we will Add Retry policies etc later | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This function is valid, accepts a Customer in JSON format as Input, Outputs a Customer and an error | |
func workflowGreetings(ctx workflow.Context, visitor customer.Customer) (customer.Customer, error) | |
// This could be valid, accept No input and Output a Customer and Error. | |
func workflowGreetings(ctx workflow.Context) (customer.Customer, error) | |
// Accept string as input, output only an Error | |
func workflowGreetings(ctx workflow.Context, input string) error |