service

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: MulanPSL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PreStringForRouteMethod string = "RouteFor"
)

Variables

This section is empty.

Functions

func Code

func Code(servicePath string) uint16

通过服务路径获取服务码

func ConvertInterface2Bool

func ConvertInterface2Bool(v interface{}) (bool, error)

func ConvertInterface2Int

func ConvertInterface2Int(v interface{}) (int, error)

func ConvertInterface2Int16

func ConvertInterface2Int16(v interface{}) (int16, error)

func ConvertInterface2Int32

func ConvertInterface2Int32(v interface{}) (int32, error)

func ConvertInterface2Int32Array

func ConvertInterface2Int32Array(v interface{}) ([]int32, error)

func ConvertInterface2Int64

func ConvertInterface2Int64(v interface{}) (int64, error)

func ConvertInterface2Int8

func ConvertInterface2Int8(v interface{}) (int8, error)

func ConvertInterface2String

func ConvertInterface2String(v interface{}) (string, error)

func ConvertString2Int

func ConvertString2Int(value string) (iValue int, err error)

func ConvertString2Int16

func ConvertString2Int16(value string) (iValue int16, err error)

func ConvertString2Int32

func ConvertString2Int32(value string) (iValue int32, err error)

func ConvertString2Int64

func ConvertString2Int64(value string) (iValue int64, err error)

func ConvertString2Int8

func ConvertString2Int8(value string) (iValue int8, err error)

func ConvertTime2Int64

func ConvertTime2Int64(value string) (iValue int64, err error)

func DispatchByCode

func DispatchByCode(serviceCode int32, data ...interface{}) error

Dispatch dispatch message to a service handler

func DispatchByPath

func DispatchByPath(servicePath string, data ...interface{}) error

Dispatch dispatch message to a service handler

func HandlerType

func HandlerType(servicePath string) []reflect.Type

HandlerType find the input-params type

func Init

func Init(checker IHandleChecker)

func Path

func Path(serviceCode uint16) string

通过服务码获取服务路径

func Register

func Register(receiver interface{})

Register register service handlers for message

Types

type Attr

type Attr struct {
	// contains filtered or unexported fields
}

func NewAttr

func NewAttr(params map[string]interface{}) *Attr

func (*Attr) Copy

func (attr *Attr) Copy(srcAttr IAttr)

func (*Attr) CopyFromMap

func (attr *Attr) CopyFromMap(newAttr map[string]interface{})

func (*Attr) CopyToMap

func (attr *Attr) CopyToMap() map[string]interface{}

func (*Attr) Get

func (attr *Attr) Get(key string) (value interface{})

func (*Attr) GetBool

func (attr *Attr) GetBool(key string) bool

func (*Attr) GetInt

func (attr *Attr) GetInt(key string) int

func (*Attr) GetInt16

func (attr *Attr) GetInt16(key string) int16

func (*Attr) GetInt32

func (attr *Attr) GetInt32(key string) int32

func (*Attr) GetInt64

func (attr *Attr) GetInt64(key string) int64

func (*Attr) GetInt8

func (attr *Attr) GetInt8(key string) int8

func (*Attr) GetString

func (attr *Attr) GetString(key string) string

func (*Attr) Set

func (attr *Attr) Set(key string, value interface{})

type IAttr

type IAttr interface {
	Get(key string) (value interface{})
	GetBool(key string) bool
	GetInt8(key string) (value int8)
	GetInt16(key string) (value int16)
	GetInt32(key string) (value int32)
	GetInt64(key string) (value int64)
	GetInt(key string) (value int)
	GetString(key string) (value string)
	Set(key string, value interface{})
	CopyToMap() map[string]interface{}
	CopyFromMap(newAttr map[string]interface{})
	Copy(newAttr IAttr)
}

type IChannelContext

type IChannelContext interface {
	ContextAttr() channel.IAttr

	ID() string

	RemoteAddr() string

	/*发起写事件,消息将被送往管道处理*/
	Write(data interface{})

	/*发起关闭事件,消息将被送往管道处理*/
	Close()
}

type IHandleChecker

type IHandleChecker interface {
	// IsHandlerMethod decide a method is suitable handler method
	IsHandlerMethod(method reflect.Method) bool
	// AdaptArgs create the params a handler method need
	AdaptArgs(types []reflect.Type, data []interface{}) []reflect.Value
}

type IReqContext

type IReqContext IAttr

type IRouteMapper

type IRouteMapper interface {
	GetCodeForPath(reqPath string) int32
	GetPathForCode(code int32) string
}

type ISerializer

type ISerializer interface {
	Serialize(message interface{}) ([]byte, error)
}

type IServiceRequest

type IServiceRequest interface {
	ChannelContext() IChannelContext
	ReqContext() IReqContext
}

func NewSessionRequest

func NewSessionRequest(channelContext IChannelContext, reqContext IReqContext) IServiceRequest

type IServiceResponse

type IServiceResponse interface {
	Write(interface{}, ISerializer)
}

type Request

type Request struct {
	// contains filtered or unexported fields
}

func (*Request) ChannelContext

func (req *Request) ChannelContext() IChannelContext

func (*Request) ReqContext

func (req *Request) ReqContext() IReqContext

Jump to

Keyboard shortcuts

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