Go SDK of china national video game anti-addiction system.
alpha(used in production)
-
idcard check
c := auth.NewClient(appId, bizId, secretKey) req := idcard.CheckRequest{IDNum:"xx", Name:"xx", AI:"xx"} resp, err := req.Do(c)
-
idcard query
req := idcard.QueryRequest{AI:"xx"} resp, err := req.Do(c)
-
behavior upload
events := []behavior.LoginOutEvent{{}, {}} req := behavior.LoginOutRequest{Collection: events} resp, err := req.Do(c)
-
message queue and producer, consumer
c := auth.NewClient(appId, bizId, secretKey) queue, err := redisstream.New(redisUrl, "behavior") // producer obj := behavior.NewLogin(...) // or NewLogout(...) data, _ := json.Marshal(obj) err = queue.Write(data) // consumer c := auth.NewClient(appId, bizId, secretKey) consumerFunc := behavior.ConsumerFunc(c, 128, 100) consumer := consumer.New(queue, consumerFunc) consumer.Start() // consumer(manually) msgList, err := queue.Read(1024, 1*time.Second) reqList, err := behavior.DecodeLoginOutRequest(msgList, 128) for _, req := range reqList { resp, err := req.Do(c) }
out-of-box way
c := auth.NewClient(appId, bizId, secretKey)
gaa, err := outofbox.New(c, redisUrl)
gaa.Start(nil)
gaa.PushBehavior(xxx)
gaa.PushQueryRequest(xxx)
MIT License