proto

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2021 License: BSD-3-Clause Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VersionKey = `Accept`

	UUIDKey       = `X-Request-ID`
	StatusCodeKey = `X-Status`

	SignKey = `Signature`

	ContentTypeKey         = `Content-Type`
	ContentTypeJSONValue   = `application/json; charset=utf-8`
	ContentTypeBinaryValue = `application/octet-stream`

	StatusCodeFail         uint = 0
	StatusCodeOK           uint = 1
	StatusCodeNotFound     uint = 2
	StatusCodeUnauthorized uint = 3
	StatusCodeForbidden    uint = 4
	StatusCodeServerError  uint = 5
	StatusCodeRedirect     uint = 6
)

nolint: golint

Variables

View Source
var (
	ErrServAlreadyRunning = errors.New("server is already running")
	ErrEpollEmptyEvents   = errors.New("epoll events is empty")
	ErrInvalidSignature   = errors.New(`invalid signature format`)
	ErrEmptyPool          = errors.New(`pool is empty`)
	ErrInvalidPoolAddress = errors.New(`invalid address in pool`)
	ErrClientNotFound     = errors.New(`client not found`)
	ErrCookieNotFound     = errors.New(`cookie not found`)
)

nolint: golint

Functions

func Code2HTTPCode

func Code2HTTPCode(v uint) int

Code2HTTPCode ...

func CreateUUID

func CreateUUID() string

CreateUUID ...

func GetFD

func GetFD(c net.Conn) int

GetFD ...

func HTTPCode2Code

func HTTPCode2Code(v int) uint

HTTPCode2Code ...

func RandomPort

func RandomPort(host string) (string, error)

RandomPort ...

func Reader

func Reader(rc io.ReadCloser) ([]byte, error)

Reader ...

Types

type CliCaller

type CliCaller func(pool Pooler, in *Request, out *Response) error

CliCaller ...

type Client

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

Client ...

func NewClient

func NewClient(conf Configer) *Client

NewClient ...

func (*Client) Call

func (o *Client) Call(name string, in *Request, out *Response) error

Call ...

func (*Client) Client

func (o *Client) Client(name string, call CliCaller)

Client ...

type Common

type Common struct {
	Meta http.Header
	Body []byte
	// contains filtered or unexported fields
}

Common ...

func (*Common) CreateSign

func (o *Common) CreateSign(s *Signer)

CreateSign ...

func (*Common) DecodeGob

func (o *Common) DecodeGob(v interface{}) error

DecodeGob ...

func (*Common) DecodeJSON

func (o *Common) DecodeJSON(v interface{}) error

DecodeJSON ...

func (*Common) EncodeGob

func (o *Common) EncodeGob(v interface{}) (err error)

EncodeGob ...

func (*Common) EncodeJSON

func (o *Common) EncodeJSON(v interface{}) (err error)

EncodeJSON ...

func (*Common) GetCookie

func (o *Common) GetCookie(name string) (*http.Cookie, error)

GetCookie ...

func (*Common) GetSignature

func (o *Common) GetSignature() (s Sign, err error)

GetSignature ...

func (*Common) GetUUID

func (o *Common) GetUUID() string

GetUUID ...

func (*Common) SetCookie

func (o *Common) SetCookie(v ...*http.Cookie)

SetCookie ...

func (*Common) SetMeta

func (o *Common) SetMeta(m map[string]string)

SetMeta ...

func (*Common) SetUUID

func (o *Common) SetUUID(v string)

SetUUID ...

func (*Common) UpdateUUID

func (o *Common) UpdateUUID()

UpdateUUID ...

func (*Common) ValidateSign

func (o *Common) ValidateSign(s *Signer) bool

ValidateSign ...

type Configer

type Configer interface {
	Get(name string) List
}

Configer ...

type List

type List []string

List ...

func (List) Pool

func (v List) Pool() (string, string, error)

Pool ...

type Pool

type Pool struct {
	Items map[string]List `yaml:"services" json:"services"`
}

Pool ...

func (Pool) Get

func (c Pool) Get(name string) List

Get ...

type Pooler

type Pooler interface {
	Pool() (string, string, error)
}

Pooler ...

type Request

type Request struct {
	Common
	URL *url.URL
}

Request model

func NewRequest

func NewRequest() *Request

NewRequest make new request

func (*Request) GetVersion

func (r *Request) GetVersion() uint64

GetVersion ...

func (*Request) SetVersion

func (r *Request) SetVersion(v uint64)

SetVersion ...

func (*Request) UpdateFromHTTP

func (r *Request) UpdateFromHTTP(v *http.Request, headers ...string) (err error)

UpdateFromHTTP ...

type Response

type Response struct {
	Common
}

Response model

func NewResponse

func NewResponse() *Response

NewResponse make new response

func (*Response) GetStatusCode

func (r *Response) GetStatusCode() uint

GetStatusCode ...

func (*Response) SetStatusCode

func (r *Response) SetStatusCode(v uint)

SetStatusCode ...

func (*Response) UpdateFromHTTP

func (r *Response) UpdateFromHTTP(v *http.Response, headers ...string) (err error)

UpdateFromHTTP ...

func (*Response) WriteToHTTP

func (r *Response) WriteToHTTP(w http.ResponseWriter) error

WriteToHTTP ...

type Server

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

Server ...

func NewServer

func NewServer() *Server

NewServer ...

func (*Server) Call

func (o *Server) Call(in *Request, out *Response)

Call ...

func (*Server) Handler

func (o *Server) Handler(path string, ver uint64, call SrvCaller)

Handler ...

type Sign

type Sign struct {
	ID        string
	Algorithm string
	Signature string
}

Sign ...

type Signer

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

Signer ...

func NewCustomSigner

func NewCustomSigner(id, secret string, h func() hash.Hash) *Signer

NewCustomSigner ...

func NewSigner

func NewSigner(id, secret string) *Signer

NewSigner ...

func (*Signer) Create

func (s *Signer) Create(b []byte) []byte

Create ...

func (*Signer) CreateString

func (s *Signer) CreateString(b []byte) string

CreateString ...

func (*Signer) ID

func (s *Signer) ID() string

ID ...

func (*Signer) Validate

func (s *Signer) Validate(b []byte, ex string) bool

Validate ...

type SrvCaller

type SrvCaller func(in *Request, out *Response)

SrvCaller ...

Jump to

Keyboard shortcuts

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