server

package
v0.0.0-...-cac6522 Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRegisterMethods

func GetRegisterMethods(name string) ([]string, error)

func NewService

func NewService(opts ...Option) *service

func Open

func Open(address string, ops ...netpoll.Option) (netpoll.EventLoop, error)

Open open address with netpoll.Option opts disable WithOnPrepare and WithOnConnect

func Register

func Register(rcvr any, name string, opts ...Option) error

Register publishes uses the provided name in the dispatcher the set of methods of the receiver value that satisfy the following conditions:

  • exported method of exported type
  • two arguments, both of exported type
  • the second argument is a pointer
  • one return value, of type error

It returns an error if the receiver is not an exported type or has no suitable methods. It also logs the error using package log. The client accesses each method using a string of the form "Type.Method", where Type is the receiver's concrete type.

func SetRecoveryHandler

func SetRecoveryHandler(handle func(string, any))

By default, it will print the time and stack information of the error

func Shutdown

func Shutdown(eventLoop netpoll.EventLoop, timeout time.Duration)

Types

type AccessHandle

type AccessHandle func(ctx *SkynetContext, sname, method string, cost time.Duration, err error)

type Dispatcher

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

dispatcher represents an RPC disoatcher.

func GetDispatcher

func GetDispatcher() *Dispatcher

func (*Dispatcher) DispatchReq

func (disp *Dispatcher) DispatchReq(sname string, methodName string, data []byte, isPush bool) ([]byte, error)

type GateAgent

type GateAgent struct {
	Reader chan netpoll.Reader // use for reader socker data
	// contains filtered or unexported fields
}

func NewGateAgent

func NewGateAgent(conn netpoll.Connection) *GateAgent

func (*GateAgent) Dispatch

func (agent *GateAgent) Dispatch(req *codec.ReqPack)

func (*GateAgent) ResponseErr

func (agent *GateAgent) ResponseErr(session uint32, err error)

func (*GateAgent) ResponseOk

func (agent *GateAgent) ResponseOk(session uint32, payload []byte)

func (*GateAgent) Start

func (agent *GateAgent) Start()

type Option

type Option func(*Options)

func WithAccessLog

func WithAccessLog(hdl AccessHandle) Option

func WithPayloadCodec

func WithPayloadCodec(c codec.PayloadCodec) Option

type Options

type Options struct {
	PayloadCodec codec.PayloadCodec
	AccessHdle   AccessHandle
}

type SkynetContext

type SkynetContext struct {
	context.Context
	// contains filtered or unexported fields
}

func NewSkynetContext

func NewSkynetContext(ctx context.Context) *SkynetContext

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳