microgo

package module
v0.0.0-...-e4fe77d Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: MIT Imports: 23 Imported by: 0

README

microgo

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotSupportContentType = fmt.Errorf("not support content type")
	ErrFullBodyLen           = fmt.Errorf("full body lenght")
	ErrBadConnection         = fmt.Errorf("bad connection")
	ErrNotFoundConnection    = fmt.Errorf("not found connection")
)

Functions

func RegisterEncoder

func RegisterEncoder(enc Encoder)

func RegisterServer

func RegisterServer(servers ...Server)

func Run

func Run() error

Types

type Call

type Call func(ctx context.Context, impl any, enc Encoder, method string, input []byte) (output []byte, err error)

type Client

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

func NewClient

func NewClient(name string, options ...ClientOption) *Client

func (*Client) BroadcastCall

func (client *Client) BroadcastCall(ctx context.Context, contentType, method string, input []byte) (map[string][]byte, map[string]error)

func (*Client) Call

func (client *Client) Call(ctx context.Context, host, contentType, method string, input []byte) (out []byte, err error)

type ClientOption

type ClientOption func(client *Client)

func WithClientOptionHosts

func WithClientOptionHosts(hosts ...string) ClientOption

type CompressType

type CompressType uint8
const (
	CompressType_Gzip CompressType = 0x10
)

type Discovery

type Discovery interface {
	QueryRoute(name string) ([]string, error)
}

type Encoder

type Encoder interface {
	Marshal(v any) ([]byte, error)
	Unmarshal(bs []byte, v any) error
	Name() string
}

func GetEncoder

func GetEncoder(name string) Encoder

type Message

type Message struct {
	BodyLen      int32
	Type         MessageType
	ContentType  MessageContentType
	CompressType CompressType
	Data         *pb.Message
}

type MessageContentType

type MessageContentType uint8
const (
	MessageContentType_Json  MessageContentType = 0x01
	MessageContentType_Proto MessageContentType = 0x02
)

type MessageType

type MessageType uint8
const (
	MessageType_Ping MessageType = 0x10
	MessageType_Data MessageType = 0x20
)

type ReadData

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

type Registry

type Registry interface {
	Register(name string, addr string) error
	UnRegister(name string, addr string) error
	KeepAlive(name string, addr string) error
}

type Server

type Server interface {
	Start() error
	Stop() error
	Name() string
	Addr() string
}

func NewHttpServer

func NewHttpServer(name string, mux http.Handler) Server

func NewTCPServer

func NewTCPServer(name string, impl any, call Call) Server

type ServerHTTP

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

func (*ServerHTTP) Addr

func (srv *ServerHTTP) Addr() string

func (*ServerHTTP) Name

func (srv *ServerHTTP) Name() string

func (*ServerHTTP) ServeHTTP

func (srv *ServerHTTP) ServeHTTP(rw http.ResponseWriter, req *http.Request)

func (*ServerHTTP) Start

func (srv *ServerHTTP) Start() error

func (*ServerHTTP) Stop

func (srv *ServerHTTP) Stop() error

type ServerTCP

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

func (*ServerTCP) Addr

func (srv *ServerTCP) Addr() string

func (*ServerTCP) Name

func (srv *ServerTCP) Name() string

func (*ServerTCP) Start

func (srv *ServerTCP) Start() error

func (*ServerTCP) Stop

func (srv *ServerTCP) Stop() error

Directories

Path Synopsis
cmd
protoc-gen-microgo
protoc-gen-go-fifi is a plugin for the Google protocol buffer compiler to generate Go code.
protoc-gen-go-fifi is a plugin for the Google protocol buffer compiler to generate Go code.
example
internal
utils

Jump to

Keyboard shortcuts

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