server

package
v0.0.0-...-7429660 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BreakerPlugin

func BreakerPlugin(c *Context)

func RatelimitPlugin

func RatelimitPlugin(c *Context)

Types

type Both

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

func (*Both) GetPaths

func (b *Both) GetPaths() []string

func (*Both) Handle

func (b *Both) Handle(h Handler) error

func (*Both) NewHandler

func (b *Both) NewHandler(handler interface{}, opts ...HandlerOption) Handler

func (*Both) Start

func (b *Both) Start() error

func (*Both) Stop

func (b *Both) Stop() error

func (*Both) Use

func (b *Both) Use(list ...Plugin) Server

type Context

type Context struct {
	Ctx        context.Context
	Service    string
	Method     string
	RemoteAddr string
	Namespace  string
	Peer       string // 包含app_name的上游service_name
	Code       int32

	// rpc request raw header
	Header map[string]string

	// rpc request raw body
	Body     []byte
	Request  interface{}
	Response interface{}
	// contains filtered or unexported fields
}

func (*Context) AbortErr

func (c *Context) AbortErr(err error)

func (*Context) Err

func (c *Context) Err() error

func (*Context) Next

func (c *Context) Next()

type Handler

type Handler interface {
	Name() string
	Handler() interface{}
}

type HandlerOption

type HandlerOption func(*HandlerOptions)

func HandlerName

func HandlerName(name string) HandlerOption

type HandlerOptions

type HandlerOptions struct {
	HandlerName string
}

type Option

type Option func(*Options)

func Address

func Address(a string) Option

Address to bind to - host:port

func Breaker

func Breaker(config *breaker.Config) Option

func Codec

func Codec(c codec.Codec) Option

Codec to use to encode/decode requests for a given content type

func Limiter

func Limiter(config *ratelimit.Config) Option

func LoggerKit

func LoggerKit(kit log.Kit) Option

func Manager

func Manager(b *registry.ServiceManager) Option

func Name

func Name(n string) Option

func Registry

func Registry(r registry.Backend) Option

func Tags

func Tags(tags map[string]string) Option

func Tracer

func Tracer(tracer opentracing.Tracer) Option

type Options

type Options struct {
	Codec    codec.Codec
	Address  string
	Name     string
	Tracer   opentracing.Tracer
	Kit      log.Kit
	Manager  *registry.ServiceManager
	Tags     map[string]string
	Registry registry.Backend
	Limiter  *ratelimit.Config
	Breaker  *breaker.Config
}

type Plugin

type Plugin func(c *Context)

type Server

type Server interface {
	NewHandler(interface{}, ...HandlerOption) Handler

	// registe a Handler to server
	Handle(Handler) error

	// registe middlewares to a handler
	Use(...Plugin) Server

	Start() error
	Stop() error

	GetPaths() []string
}

func BinaryServer

func BinaryServer(options ...Option) Server

func BothServer

func BothServer(serviceName string, port int, options ...Option) Server

func HTTPServer

func HTTPServer(options ...Option) Server

Jump to

Keyboard shortcuts

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