本文整理汇总了Golang中github.com/sclasen/swfsm/migrator.DomainMigrator.States方法的典型用法代码示例。如果您正苦于以下问题:Golang DomainMigrator.States方法的具体用法?Golang DomainMigrator.States怎么用?Golang DomainMigrator.States使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/sclasen/swfsm/migrator.DomainMigrator
的用法示例。
在下文中一共展示了DomainMigrator.States方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestClient
func TestClient(t *testing.T) {
if os.Getenv("AWS_ACCESS_KEY_ID") == "" || os.Getenv("AWS_SECRET_ACCESS_KEY") == "" {
Log.Printf("WARNING: NO AWS CREDS SPECIFIED, SKIPPING MIGRATIONS TEST")
return
}
config := &aws.Config{
Credentials: credentials.NewEnvCredentials(),
Region: aws.String("us-east-1"),
}
client := swf.New(session.New(config))
req := swf.RegisterDomainInput{
Name: aws.String("client-test"),
Description: aws.String("test domain"),
WorkflowExecutionRetentionPeriodInDays: aws.String("30"),
}
d := migrator.DomainMigrator{
RegisteredDomains: []swf.RegisterDomainInput{req},
Client: client,
}
d.Migrate()
wreq := swf.RegisterWorkflowTypeInput{
Name: aws.String("client-test"),
Description: aws.String("test workflow migration"),
Version: aws.String("1"),
Domain: aws.String("client-test"),
}
w := migrator.WorkflowTypeMigrator{
RegisteredWorkflowTypes: []swf.RegisterWorkflowTypeInput{wreq},
Client: client,
}
w.Migrate()
fsm := &FSM{
Domain: "client-test",
Name: "client-test",
DataType: TestData{},
Serializer: JSONStateSerializer{},
SystemSerializer: JSONStateSerializer{},
AllowPanics: false,
}
fsm.AddInitialState(&FSMState{Name: "initial",
Decider: func(ctx *FSMContext, h *swf.HistoryEvent, data interface{}) Outcome {
if *h.EventType == swf.EventTypeWorkflowExecutionSignaled {
d := data.(*TestData)
d.States = append(d.States, *h.WorkflowExecutionSignaledEventAttributes.SignalName)
}
return ctx.Stay(data, ctx.EmptyDecisions())
},
})
fsmClient := NewFSMClient(fsm, client)
workflow := uuid.New()
testData := uuid.New()
startTemplate := swf.StartWorkflowExecutionInput{
WorkflowType: &swf.WorkflowType{Name: aws.String("client-test"), Version: aws.String("1")},
ExecutionStartToCloseTimeout: aws.String("120"),
TaskStartToCloseTimeout: aws.String("120"),
ChildPolicy: aws.String("ABANDON"),
TaskList: &swf.TaskList{Name: aws.String("task-list")},
}
_, err := fsmClient.Start(startTemplate, workflow, &TestData{States: []string{testData}})
if err != nil {
t.Fatal(err)
}
state, data, err := fsmClient.GetState(workflow)
if err != nil {
t.Fatal(err)
}
if data.(*TestData).States[0] != testData {
t.Fatal(data)
}
if state != "initial" {
t.Fatal("not in initial")
}
found := false
err = fsmClient.WalkOpenWorkflowInfos(&swf.ListOpenWorkflowExecutionsInput{}, func(infos *swf.WorkflowExecutionInfos) error {
for _, info := range infos.ExecutionInfos {
if *info.Execution.WorkflowId == workflow {
found = true
return StopWalking()
}
}
return nil
})
if err != nil {
//.........这里部分代码省略.........