model

package
v0.0.0-...-0dc16ad Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// behavior:(app):model:(modelID)
	ModelNodeKey = "behavior:%s:process-on-node:%s"
	// behavior:(app):node:list:(nodeID)
	NodeListKey = "behavior:%s:node-process-list:%s"
	// behavior:(app):node:addr:(nodeID)
	NodeAddrKey = "behavior:%s:node-addr:%s:%s"
	// behavior:(app):dead_node
	DeadNodeKey = "behavior:%s:dead_node"
)
View Source
const (
	C2S = "c2s"
	S2S = "s2s"
)

for NodeAddrKey

View Source
const (
	MaxModelCount       uint32 = 10000
	SafeModelCount      uint32 = 1000
	WarningModelCountL1 uint32 = 5000
	WarningModelCountL2 uint32 = 6000
	WarningModelCountL3 uint32 = 7000
)
View Source
const (
	RetryCount   uint8         = 3
	RetrySeconds time.Duration = 60 * time.Minute
)

for retry

View Source
const (
	LiveTime        time.Duration = 20 * time.Minute
	LiveTimeWarning time.Duration = 1 * time.Minute
)

LiveTime duration

View Source
const (
	NullString string = ""
	Zero       uint64 = 0
	ZeroUint8  uint8  = 0
	One        uint64 = 1
)

default value

View Source
const (
	ResultOK uint32 = iota
	ErrSocketErr
	ErrUnCodeErr
	ErrParamErr
)

error code

View Source
const ChanMaxLen uint8 = 20
View Source
const CleanDuration time.Duration = 30 * time.Second
View Source
const (
	IPVersion string = "tcp4"
)

conn

View Source
const IsGlobal = false

IsGlobal modify

View Source
const RedisAddr = "127.0.0.1:6379"

Variables

View Source
var ClusterCenter *clusterCenter

go-zero的redis可以处理集群,所以用它的redis

Functions

func GetId

func GetId(key string) (uint64, error)

func InitCluster

func InitCluster(app, nodeName string, s2s bool, s2sPort uint)

func SentInfo

func SentInfo(protoID uint64, data []byte, from, to string, safe bool) error

func SentStop

func SentStop(from, to string) (*model, error)

func SentSync

func SentSync(protoID uint64, data []byte, from, to string, chanSize uint8, safe bool) ([]byte, error)

func SentSyncLocal

func SentSyncLocal(protoID uint64, data []byte, from, to string, chanSize uint8, safe bool) ([]byte, error)

func SetDefaultFunc

func SetDefaultFunc(defaultFun func() bool) opt

func SetIsGlobal

func SetIsGlobal(isGlobal bool) opt

func SetLiveTime

func SetLiveTime(minutes int) opt

func SetRetry

func SetRetry(count uint8, seconds uint32) opt

Types

type Data

type Data struct {
	ProtoID uint64
	Data    []byte
}

type Handler

type Handler interface {
	HandlerStop() Handler
	HandlerInfo(*Message) Handler
	HandlerSync(*SyncMessage) ([]byte, Handler)
}

func OnThisNode

func OnThisNode(name string) (bool, Handler)

type Message

type Message struct {
	From string
	Data *Data
}

type QuickHandel

type QuickHandel struct {
	Name string
}

func (*QuickHandel) HandlerAsync

func (qh *QuickHandel) HandlerAsync(msg *Message) (Handler, *Message)

func (*QuickHandel) HandlerInfo

func (qh *QuickHandel) HandlerInfo(msg *Message) Handler

func (*QuickHandel) HandlerStop

func (qh *QuickHandel) HandlerStop() Handler

func (*QuickHandel) HandlerSync

func (qh *QuickHandel) HandlerSync(msg *SyncMessage) ([]byte, Handler)

func (*QuickHandel) Run

func (qh *QuickHandel) Run(data Handler, opts ...opt) error

func (*QuickHandel) SafeRun

func (qh *QuickHandel) SafeRun(data Handler, opts ...opt) error

func (*QuickHandel) SafeSendInfo

func (qh *QuickHandel) SafeSendInfo(to string, protoID uint64, data []byte) error

func (*QuickHandel) SendInfo

func (qh *QuickHandel) SendInfo(to string, protoID uint64, data []byte) error

func (*QuickHandel) SendStop

func (qh *QuickHandel) SendStop(to string) (*model, error)

func (*QuickHandel) SendSync

func (qh *QuickHandel) SendSync(to string, protoID uint64, data []byte) ([]byte, error)

type SafeHandel

type SafeHandel struct {
	Name string
}

func (*SafeHandel) HandlerAsync

func (h *SafeHandel) HandlerAsync(msg *Message) (Handler, *Message)

func (*SafeHandel) HandlerInfo

func (h *SafeHandel) HandlerInfo(msg *Message) Handler

func (*SafeHandel) HandlerStop

func (h *SafeHandel) HandlerStop() Handler

func (*SafeHandel) HandlerSync

func (h *SafeHandel) HandlerSync(msg *SyncMessage) ([]byte, Handler)

func (*SafeHandel) QuickRun

func (h *SafeHandel) QuickRun(data Handler, opts ...opt) error

func (*SafeHandel) QuickSendInfo

func (h *SafeHandel) QuickSendInfo(to string, protoID uint64, data []byte) error

func (*SafeHandel) Run

func (h *SafeHandel) Run(data Handler, opts ...opt) error

func (*SafeHandel) SendInfo

func (h *SafeHandel) SendInfo(to string, protoID uint64, data []byte) error

func (*SafeHandel) SendStop

func (h *SafeHandel) SendStop(to string) (*model, error)

func (*SafeHandel) SendSync

func (h *SafeHandel) SendSync(to string, protoID uint64, data []byte) ([]byte, error)

type SyncMessage

type SyncMessage struct {
	From string
	Data *Data
	// contains filtered or unexported fields
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL