修改状态机的写法
This commit is contained in:
parent
ca80a94f72
commit
1913beb3f7
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/auth/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/auth"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
@ -18,7 +18,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -28,7 +28,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/backend/internal/config"
|
||||
"fusenapi/shared"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/canteen/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/data-transfer/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package svc
|
||||
|
||||
import (
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/initalize"
|
||||
"fusenapi/model/gmodel"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
|
||||
"github.com/golang-jwt/jwt"
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/inventory/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/map-library/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/orders/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/pay/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/product-template-tag/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/product/internal/config"
|
||||
"fusenapi/shared"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/initalize"
|
||||
|
@ -16,7 +16,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/render/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -26,7 +26,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -15,7 +15,7 @@ func LogoCombineHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
|
|||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
var req types.LogoCombineReq
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx, &req)
|
||||
userinfo, err := basic.RequestParse(w, r, svcCtx.SharedState, &req)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/resource/internal/config"
|
||||
"fusenapi/shared"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/initalize"
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/shopping-cart-confirmation/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/upload/internal/config"
|
||||
"fusenapi/shared"
|
||||
"net/http"
|
||||
|
||||
"fusenapi/initalize"
|
||||
|
@ -19,7 +19,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/webset/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -25,7 +25,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -3,8 +3,8 @@ package svc
|
|||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/server/websocket/internal/config"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/autoconfig"
|
||||
"net/http"
|
||||
|
||||
|
@ -17,7 +17,7 @@ import (
|
|||
|
||||
type ServiceContext struct {
|
||||
Config config.Config
|
||||
SharedState *fsm.SharedState
|
||||
SharedState *shared.SharedState
|
||||
|
||||
MysqlConn *gorm.DB
|
||||
AllModels *gmodel.AllModelsGen
|
||||
|
@ -26,7 +26,7 @@ type ServiceContext struct {
|
|||
|
||||
func NewServiceContext(c config.Config) *ServiceContext {
|
||||
conn := initalize.InitMysql(c.SourceMysql)
|
||||
StateServer := fsm.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
StateServer := shared.StartNode(c.ReplicaId, autoconfig.AutoGetAllServerConfig(), conn)
|
||||
|
||||
return &ServiceContext{
|
||||
Config: c,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package fsm
|
||||
package shared
|
||||
|
||||
import (
|
||||
"bytes"
|
|
@ -1,4 +1,4 @@
|
|||
package fsm
|
||||
package shared
|
||||
|
||||
import "testing"
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package fsm
|
||||
package shared
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
@ -25,11 +25,6 @@ func (ss *SharedState) GetUserState(Userid int64) (us *UserState, err error) {
|
|||
return ius.(*UserState), nil
|
||||
}
|
||||
|
||||
// cmd := &Command{
|
||||
// Op: OP_Update,
|
||||
// Key: Userid,
|
||||
// }
|
||||
|
||||
cs := ss.nh.GetNoOPSession(128)
|
||||
|
||||
cmd := &CmdUpdate{UserId: Userid}
|
|
@ -1,4 +1,4 @@
|
|||
package fsm
|
||||
package shared
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -1,4 +1,4 @@
|
|||
package fsm
|
||||
package shared
|
||||
|
||||
import (
|
||||
"context"
|
|
@ -2,7 +2,7 @@ package basic
|
|||
|
||||
import (
|
||||
"errors"
|
||||
"fusenapi/fsm"
|
||||
"fusenapi/shared"
|
||||
"fusenapi/utils/auth"
|
||||
"net/http"
|
||||
"reflect"
|
||||
|
@ -51,7 +51,7 @@ func NormalAfterLogic(w http.ResponseWriter, r *http.Request, resp *Response) {
|
|||
}
|
||||
}
|
||||
|
||||
func RequestParse(w http.ResponseWriter, r *http.Request, state *fsm.SharedState, LogicRequest any) (*auth.UserInfo, error) {
|
||||
func RequestParse(w http.ResponseWriter, r *http.Request, state *shared.SharedState, LogicRequest any) (*auth.UserInfo, error) {
|
||||
// log.Println(io.ReadAll(r.Body))
|
||||
token, info, err := auth.ParseJwtTokenHeader[auth.UserInfo](r) //解析Token头, 和payload信息
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in New Issue
Block a user