dtm/app/main.go
2021-06-03 15:11:03 +08:00

37 lines
741 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package main
import (
"os"
"time"
"github.com/sirupsen/logrus"
"github.com/yedf/dtm/dtmsvr"
"github.com/yedf/dtm/examples"
)
type M = map[string]interface{}
func main() {
if len(os.Args) == 1 { // 默认情况下展示saga例子
dtmsvr.PopulateMysql()
go dtmsvr.StartSvr()
go examples.SagaStartSvr()
time.Sleep(100 * time.Millisecond)
examples.SagaFireRequest()
} else if os.Args[1] == "dtmsvr" {
go dtmsvr.StartSvr()
} else if os.Args[1] == "all" {
dtmsvr.PopulateMysql()
examples.PopulateMysql()
go dtmsvr.StartSvr()
go examples.SagaStartSvr()
go examples.TccStartSvr()
go examples.XaStartSvr()
} else {
logrus.Fatalf("unknown arg: %s", os.Args[1])
}
for {
time.Sleep(1000 * time.Second)
}
}