oecho

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// HeaderAcceptEncoding ...
	HeaderAcceptEncoding = "Accept-Encoding"
	// HeaderContentType ...
	HeaderContentType = "Content-Type"
	// HRPC Errord
	HeaderHRPCErr = "HRPC-Errord"
)

Headers

View Source
const (
	// MIMEApplicationJSON ...
	MIMEApplicationJSON = "application/json"
	// MIMEApplicationJSONCharsetUTF8 ...
	MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8
	// MIMEApplicationProtobuf ...
	MIMEApplicationProtobuf = "application/protobuf"
)

MIME types

View Source
const ModName = "server.echo"

ModName named a mod

Variables

View Source
var (
	// ErrGRPCResponseValid ...
	ErrGRPCResponseValid = grpc.Errorf(codes.Internal, "response valid")
	// ErrGRPCInvokeLen ...
	ErrGRPCInvokeLen = grpc.Errorf(codes.Internal, "invoke request without len 2 res")
)
View Source
var ErrNotFound = HTTPError{
	Code:    http.StatusNotFound,
	Message: "not found",
}

ErrNotFound defines StatusNotFound error.

Functions

func GRPCProxyWrapper

func GRPCProxyWrapper(h interface{}) echo.HandlerFunc

GRPCProxyWrapper ...

func ProtoError

func ProtoError(c echo.Context, code int, e error) error

ProtoError ...

func ProtoJSON

func ProtoJSON(c echo.Context, code int, i interface{}) error

ProtoJSON sends a Protobuf JSON response with status code and data.

Types

type Config

type Config struct {
	Host          string
	Port          int
	Deployment    string
	Debug         bool
	DisableMetric bool
	DisableTrace  bool
	// ServiceAddress service address in registry info, default to 'Host:Port'
	ServiceAddress string

	SlowQueryThresholdInMilli int64
	// contains filtered or unexported fields
}

Config HTTP config

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig ...

func RawConfig

func RawConfig(key string) *Config

RawConfig ...

func StdConfig

func StdConfig(name string) *Config

StdConfig Ox Standard HTTP Server config

func (*Config) Address

func (config *Config) Address() string

Address ...

func (*Config) Build

func (config *Config) Build() (*Server, error)

Build create server instance, then initialize it with necessary interceptor

func (*Config) MustBuild

func (config *Config) MustBuild() *Server

func (*Config) WithHost

func (config *Config) WithHost(host string) *Config

WithHost ...

func (*Config) WithLogger

func (config *Config) WithLogger(logger *olog.Logger) *Config

WithLogger ...

func (*Config) WithPort

func (config *Config) WithPort(port int) *Config

WithPort ...

type EmptyMessage

type EmptyMessage struct{}

EmptyMessage ...

func (*EmptyMessage) ProtoMessage

func (*EmptyMessage) ProtoMessage()

ProtoMessage ...

func (*EmptyMessage) Reset

func (m *EmptyMessage) Reset()

Reset ...

func (*EmptyMessage) String

func (m *EmptyMessage) String() string

String ...

type GRPCProxyMessage

type GRPCProxyMessage struct {
	Error   int           `protobuf:"varint,1,opt,name=error" json:"error"`
	Message string        `protobuf:"bytes,2,opt,name=msg" json:"msg"`
	Data    proto.Message `protobuf:"bytes,3,opt,name=data" json:"data"`
}

GRPCProxyMessage ...

func (*GRPCProxyMessage) MarshalJSONPB

func (m *GRPCProxyMessage) MarshalJSONPB(jsb *jsonpb.Marshaler) ([]byte, error)

MarshalJSONPB ...

func (*GRPCProxyMessage) ProtoMessage

func (*GRPCProxyMessage) ProtoMessage()

ProtoMessage ...

func (*GRPCProxyMessage) Reset

func (m *GRPCProxyMessage) Reset()

Reset ...

func (*GRPCProxyMessage) String

func (m *GRPCProxyMessage) String() string

String ...

type HTTPError

type HTTPError struct {
	Code    int
	Message string
}

HTTPError wraps handler error.

func NewHTTPError

func NewHTTPError(code int, msg ...string) *HTTPError

NewHTTPError constructs a new HTTPError instance.

func (HTTPError) Error

func (e HTTPError) Error() string

Errord return error message.

type Server

type Server struct {
	*echo.Echo
	// contains filtered or unexported fields
}

Server ...

func (*Server) GracefulStop

func (s *Server) GracefulStop(ctx context.Context) error

GracefulStop implements server.Server interface it will stop echo server gracefully

func (*Server) Healthz

func (s *Server) Healthz() bool

func (*Server) Info

func (s *Server) Info() *server.ServiceInfo

Info returns server info, used by governor and consumer balancer

func (*Server) Serve

func (s *Server) Serve() error

Server implements server.Server interface.

func (*Server) Stop

func (s *Server) Stop() error

Stop implements server.Server interface it will terminate echo server immediately

Jump to

Keyboard shortcuts

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