golum

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2019 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	StatusSuccess = 0
	StatusError   = 1
)

golum status code.

Variables

View Source
var DefaultServeMux = &ServeMux{}

DefaultServeMux : TODO

View Source
var ErrServerClosed = errors.New("server closed")

ErrServerClosed : TODO

Functions

func HandleFunc

func HandleFunc(typ string, handler func(w io.Writer, r *Request))

HandleFunc : TODO

func NotFound

func NotFound(w io.Writer, r *Request)

NotFound : TODO

func RenderError

func RenderError(w io.Writer, err error)

RenderError : TODO

func RenderResponse

func RenderResponse(w io.Writer, body []byte)

RenderResponse : TODO

Types

type Client

type Client struct {
	// SocketName specifies the UNIX domain socket file name.
	SocketName string
	Timeout    time.Duration
}

Client is a golum client.

func (*Client) Do

func (c *Client) Do(req *Request) (*Response, error)

Do sends a golum request and returns a golum response.

type ConnState

type ConnState int

ConnState : TODO

const (
	// StateNew : TODO
	StateNew ConnState = iota
	// StateActive : TODO
	StateActive
	// StateIdle : TODO
	StateIdle
	// StateClosed : TODO
	StateClosed
)

func (ConnState) String

func (c ConnState) String() string

type Handler

type Handler interface {
	ServeSocket(io.Writer, *Request)
}

Handler : TODO

func NotFoundHandler

func NotFoundHandler() Handler

NotFoundHandler : TODO

type HandlerFunc

type HandlerFunc func(w io.Writer, r *Request)

HandlerFunc : TODO

func (HandlerFunc) ServeSocket

func (f HandlerFunc) ServeSocket(w io.Writer, r *Request)

ServeSocket : TODO

type Request

type Request struct {
	Type string `json:"type"`
	Body []byte `json:"body"`
}

Request represents a golum request.

func NewRequest

func NewRequest(typ string, data []byte) *Request

NewRequest returns a new Request given a type and body.

func (*Request) ToBinary

func (r *Request) ToBinary() ([]byte, error)

ToBinary encodes the Request to []byte.

type Response

type Response struct {
	Body []byte `json:"body"`
	Code int    `json:"code"`
}

Response : TODO

func (*Response) ToBinary

func (r *Response) ToBinary() ([]byte, error)

ToBinary encodes the Response to []byte.

type ServeMux

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

ServeMux : TODO

func (*ServeMux) Handle

func (m *ServeMux) Handle(typ string, handler Handler)

Handle : TODO

func (*ServeMux) HandleFunc

func (m *ServeMux) HandleFunc(typ string, handler func(w io.Writer, r *Request))

HandleFunc : TODO

func (*ServeMux) Handler

func (m *ServeMux) Handler(r *Request) (Handler, string)

Handler : TODO

func (*ServeMux) ServeSocket

func (m *ServeMux) ServeSocket(w io.Writer, r *Request)

ServeSocket : TODO

type Server

type Server struct {
	SocketName   string
	Handler      Handler
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	// contains filtered or unexported fields
}

Server : TODO

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() error

ListenAndServe : TODO

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve : TODO

func (*Server) Shutdown

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

Shutdown : TODO

Jump to

Keyboard shortcuts

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