本文整理汇总了Golang中github.com/sclasen/swfsm/migrator.DomainMigrator类的典型用法代码示例。如果您正苦于以下问题:Golang DomainMigrator类的具体用法?Golang DomainMigrator怎么用?Golang DomainMigrator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomainMigrator类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: TestTypedActivityWorker
func TestTypedActivityWorker(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))
domain := "worker-test-domain"
req := swf.RegisterDomainInput{
Name: aws.String(domain),
Description: aws.String("test domain"),
WorkflowExecutionRetentionPeriodInDays: aws.String("30"),
}
d := migrator.DomainMigrator{
RegisteredDomains: []swf.RegisterDomainInput{req},
Client: client,
}
d.Migrate()
workflow := "worker-test-workflow"
version := "worker-test-workflow-version"
wreq := swf.RegisterWorkflowTypeInput{
Name: &workflow,
Description: aws.String("test workflow migration"),
Version: &version,
Domain: aws.String(domain),
DefaultTaskList: &swf.TaskList{Name: S("worker-fsm")},
}
w := migrator.WorkflowTypeMigrator{
RegisteredWorkflowTypes: []swf.RegisterWorkflowTypeInput{wreq},
Client: client,
}
w.Migrate()
one := swf.RegisterActivityTypeInput{
Name: aws.String("one"),
Description: aws.String("worker test activity 1"),
Version: aws.String("one"),
Domain: aws.String(domain),
}
two := swf.RegisterActivityTypeInput{
Name: aws.String("two"),
Description: aws.String("worker test activity 2"),
Version: aws.String("two"),
Domain: aws.String(domain),
}
a := migrator.ActivityTypeMigrator{
RegisteredActivityTypes: []swf.RegisterActivityTypeInput{one, two},
Client: client,
}
a.Migrate()
taskList := "aTaskListSharedBetweenTaskOneAndTwo"
worker := &ActivityWorker{
Domain: domain,
Serializer: fsm.JSONStateSerializer{},
TaskList: taskList,
SWF: client,
Identity: "test-activity-worker",
}
//This is where the actual worker config code is
var activities Activities
activities = MockActivities{}
worker.AddHandler(NewActivityHandler("one", activities.Task1))
worker.AddHandler(NewActivityHandler("two", activities.Task2))
go worker.Start()
//yep thats all the worker config code
done := make(chan struct{})
go NewWorkerFSM(client, done).Start()
_, err := client.StartWorkflowExecution(&swf.StartWorkflowExecutionInput{
Domain: S(domain),
WorkflowId: S("worker-test"),
WorkflowType: &swf.WorkflowType{Name: S(workflow), Version: S(version)},
Input: S("{}"),
ExecutionStartToCloseTimeout: S("90"),
TaskStartToCloseTimeout: S("10"),
//.........这里部分代码省略.........
开发者ID:ryanwalls,项目名称:swfsm,代码行数:101,代码来源:worker_test.go
示例2: 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 {
//.........这里部分代码省略.........
开发者ID:ryanwalls,项目名称:swfsm,代码行数:101,代码来源:client_test.go
注:本文中的github.com/sclasen/swfsm/migrator.DomainMigrator类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论