module

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Copyright 2020 newtbig Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2020 newtbig Author. All Rights Reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

type App interface {
	UpdateOptions(opts ...Option) error
	Run(opts ...Option) error
	OnInit() error
	OnDestroy() error
	Options() Options
	OnRegiste(func(app App)) error
	GetProcessID() string
	WorkDir() string
	SetVerify(_func FuncVerify) error
	GetVerify() FuncVerify
	GetKeysAPI() eclient.KV
	GetEClient() *etcdclient.ETCDClient
	GetRPC() RPC
	GetDispatcher() Dispatcher
	Register(msgID uint32, msgHandler DisposeFunc)
	RegisteSer(id uint32, key string) error
	IsGate() bool
}

type CallBack

type CallBack interface {
	Respond(data []byte) error
}

type Connect

type Connect interface {
	IsClosed() bool
	OnClose()
	OnSend(d []byte) error
	OnReceive() ([]byte, error)
	OnString() string
	OnSendMsg(d *framepb.Msg) error
	OnReceiveMsg() (*framepb.Msg, error)
}

type Dispatcher

type Dispatcher interface {
	RegisteSer(id uint32, key string) error
	Route(msg *framepb.Msg) (string, error)
	RouteB(msg *framepb.Msg) ([]string, error)
	GetServer(sType string, id uint64) ([]byte, error)
	GetGate(id uint64) ([]byte, error)
	GetStatus() ([]byte, error)
	CheckRoute(key uint64) bool
	Start() error
	Stop() error
	Clear() error
}

type DisposeFunc

type DisposeFunc func(ctl interface{}, data *framepb.Msg) (rst *framepb.Msg)

type FuncVerify

type FuncVerify func(interface{}) bool

type Gate

type Gate interface {
	App
	SetVerify(_func FuncVerify) error
	GetVerify() FuncVerify
}

type Option

type Option func(*Options)

func ByteOrder

func ByteOrder(t bool) Option

func Conf

func Conf(cName string) Option

func Debug

func Debug(t bool) Option

func DisLen added in v0.1.4

func DisLen(t uint32) Option

func DisRep added in v0.1.4

func DisRep(t uint32) Option

func ExitWaitTTL

func ExitWaitTTL(t time.Duration) Option

func Metadata

func Metadata(md map[string]string) Option

func NetHeadSize

func NetHeadSize(t uint16) Option

func NetType

func NetType(nt string) Option

func Parse

func Parse(t bool) Option

func Process

func Process(p Processor) Option

func RPCExpired

func RPCExpired(t time.Duration) Option

func RPCMaxCoroutine

func RPCMaxCoroutine(t uint32) Option

func ReadDeadline

func ReadDeadline(t int64) Option

func RegisterInterval

func RegisterInterval(t time.Duration) Option

func RegisterTTL

func RegisterTTL(t int) Option

func Serv

func Serv(s Server) Option

func Version

func Version(v string) Option

func Wait

func Wait(b bool) Option

func WorkDir

func WorkDir(v string) Option

func WriteDeadline

func WriteDeadline(t int64) Option

type Options

type Options struct {
	Context           context.Context
	HostName          string
	PID               string
	Metadata          map[string]string
	Version           string
	RunMode           string
	Debug             bool
	Parse             bool
	WorkDir           string
	AppName           string
	ConfName          string
	ETCDHosts         []string
	NetType           string
	ServerType        string
	ServerName        string
	ServerIP          string
	ServerIPOut       string
	ServerPort        string
	ServerConTypes    []string
	HeartBeatInterval int64
	ExitWaitTTL       time.Duration
	RegisterInterval  time.Duration
	RegisterTTL       int
	RPCExpired        time.Duration
	RPCMaxCoroutine   uint32
	MaxConn           int32
	MaxPacketSize     int64
	ReadDeadline      int64
	WriteDeadline     int64
	RpmLimit          uint32
	MaxMsgChanLen     uint32
	NetHeadSize       uint16
	ByteOrder         bool
	NatsHosts         []string
	Serv              Server
	Process           Processor
	Rpc               RPC
	DisLen            uint32
	DisRep            uint32
}

type Processor

type Processor interface {
	GetApp() App
	Init(app App)
	Marshal(msg *framepb.Msg) ([]byte, error)
	Unmarshal(data []byte) (*framepb.Msg, error)
	HandleMsg(ctl interface{}, msg *framepb.Msg) *framepb.Msg
	Register(msgID uint32, msgHandler DisposeFunc)
	Dump()
}

type RPC

type RPC interface {
	Call(ctx context.Context, msg *framepb.Msg) (*framepb.Msg, error)
	CallNR(msg *framepb.Msg) (err error)
	CallS(msg *framepb.Msg) (err error)
	CallB(msg *framepb.Msg) (err error)
	Start() (err error)
	Stop() (err error)
	CallBack() chan *framepb.Msg
}

type Server

type Server interface {
	BeforeStart() error
	Start() error
	BeforeStop() error
	AfterStart() error
	Stop() error
	AfterStop() error
	Count() uint32
}

type Service

type Service interface {
	Server() Server
	Run() error
	String() string
}

type Session

type Session interface {
	OnStart(Connect) error
	SendByte(data []byte) error
	SendMsg(msg *framepb.Msg) error
	OnStop() error
	GetUID() uint64
	Kick() error
	SetHeartBeatTime(time time.Time)
}

Jump to

Keyboard shortcuts

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