toyframe

package module
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: MIT Imports: 12 Imported by: 2

README

toyframe

一个简单到不能再简单的玩具级别的服务开发库(甚至称之为框架都不够格= =|||)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateMethod error = errors.New("duplicate method")
View Source
var ErrInterrupted error = errors.New("interrupted")
View Source
var ErrMethodTooLong error = errors.New("method too long")

Functions

func DoWithInterruptor added in v1.0.4

func DoWithInterruptor(job func(), interrupt_ch chan struct{}) error

func InterruptableReader added in v1.0.4

func InterruptableReader(reader io.Reader, interrupt_ch chan struct{}) io.Reader

func InterruptableWriter added in v1.0.4

func InterruptableWriter(writer io.WriteCloser, interrupt_ch chan struct{}) io.WriteCloser

func SetLogWriter

func SetLogWriter(out io.Writer)

Types

type Context

type Context struct {
	Method string
	// contains filtered or unexported fields
}

func Call

func Call(network, addr, method string, dial dialer.DialFunc, params ...msgp.MarshalSizer) (*Context, error)

func CallWithInterruptor added in v1.0.4

func CallWithInterruptor(network, addr, method string, dial dialer.DialFunc, ich chan struct{}, params ...msgp.MarshalSizer) (*Context, error)

func NewContext added in v1.0.5

func NewContext(conn net.Conn) *Context

func (*Context) AddCloseHandler added in v1.0.2

func (c *Context) AddCloseHandler(cb func())

func (*Context) Close

func (c *Context) Close() error

func (*Context) LocalAddr

func (c *Context) LocalAddr() net.Addr

func (*Context) ReadObj

func (c *Context) ReadObj(obj msgp.Unmarshaler) error

func (*Context) Reader

func (c *Context) Reader() io.Reader

func (*Context) RemoteAddr

func (c *Context) RemoteAddr() net.Addr

func (*Context) SetInterruptor added in v1.0.4

func (c *Context) SetInterruptor(ich chan struct{})

func (*Context) WriteObj

func (c *Context) WriteObj(obj msgp.MarshalSizer) error

func (*Context) Writer

func (c *Context) Writer() io.Writer

type Handler

type Handler func(*Context) error

type NullWriter

type NullWriter struct{}

func (NullWriter) Write

func (w NullWriter) Write(data []byte) (int, error)

type Server

type Server interface {
	Register(method string, cb Handler) error
	AddListener(lis net.Listener) Server
	Run() error
	Close() error
	CloseChannel() chan struct{}
}

func NewServer

func NewServer() Server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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