graceful

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

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

Go to latest
Published: Feb 26, 2019 License: GPL-3.0 Imports: 23 Imported by: 8

README

godoc Build Status

graceful

Graceful is an RPC framework and protobuf service generator. It's quiet similar to gRPC but a little bit lighter.

Graceful is intended to be used for communication between QDP API and its clients. Code for QDP API already generated and committed in QDP repo, so you only need this one to have compilation succeed.

If you are looking for some general purpose RPC framework you'd better to use gRPC

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Error

func Error(w http.ResponseWriter, err error, statusCode int)

func ErrorFromURL

func ErrorFromURL(err error) error

func IsNilInterface

func IsNilInterface(v interface{}) bool

func NewHandler

func NewHandler(
	codec Codec,
	makebuf func() interface{},
	process func(context.Context, interface{}) (interface{}, error)) http.HandlerFunc

Types

type Client

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

func NewClient

func NewClient(baseurl string, codec Codec, breaker *breaker.Breaker) (*Client, error)

func (*Client) Call

func (c *Client) Call(ctx context.Context, method string, args, reply interface{}) error

func (*Client) SetRequestProcessor

func (c *Client) SetRequestProcessor(p func(*http.Request) (*http.Response, error))

type Codec

type Codec interface {
	Size(interface{}) int
	Marshal(interface{}) ([]byte, error)
	MarshalTo([]byte, interface{}) (int, error)
	Unmarshal([]byte, interface{}) error
	MIME() string
}

type CodecPack

type CodecPack struct {
	Default   Codec
	Supported map[string]Codec
}

func (*CodecPack) Codec

func (c *CodecPack) Codec(req http.Header) Codec

type FakeConn

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

func NewFakeConn

func NewFakeConn(ctx context.Context, conn net.Conn) *FakeConn

func (*FakeConn) Close

func (c *FakeConn) Close() error

func (*FakeConn) LocalAddr

func (c *FakeConn) LocalAddr() net.Addr

func (*FakeConn) Read

func (c *FakeConn) Read(b []byte) (int, error)

func (*FakeConn) RemoteAddr

func (c *FakeConn) RemoteAddr() net.Addr

func (*FakeConn) SetDeadline

func (c *FakeConn) SetDeadline(t time.Time) error

func (*FakeConn) SetReadDeadline

func (c *FakeConn) SetReadDeadline(t time.Time) error

func (*FakeConn) SetWriteDeadline

func (c *FakeConn) SetWriteDeadline(t time.Time) error

func (*FakeConn) Write

func (c *FakeConn) Write(b []byte) (int, error)

type FakeListener

type FakeListener struct {
	DefaultTransport http.RoundTripper
	// contains filtered or unexported fields
}

func NewFakeListener

func NewFakeListener() (l *FakeListener)

func (*FakeListener) Accept

func (l *FakeListener) Accept() (net.Conn, error)

func (*FakeListener) Addr

func (l *FakeListener) Addr() net.Addr

func (*FakeListener) Close

func (l *FakeListener) Close() error

type FakeRoudTripper

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

func (FakeRoudTripper) RoundTrip

func (f FakeRoudTripper) RoundTrip(req *http.Request) (*http.Response, error)

type Handlerer

type Handlerer interface {
	http.Handler
	Handle(string, http.Handler)
}

type JSONCodec

type JSONCodec struct {
}

func (*JSONCodec) MIME

func (*JSONCodec) MIME() string

func (*JSONCodec) Marshal

func (c *JSONCodec) Marshal(v interface{}) ([]byte, error)

func (*JSONCodec) MarshalTo

func (c *JSONCodec) MarshalTo(buf []byte, v interface{}) (int, error)

func (*JSONCodec) Size

func (c *JSONCodec) Size(v interface{}) int

func (*JSONCodec) Unmarshal

func (c *JSONCodec) Unmarshal(buf []byte, v interface{}) error

type ProtobufCodec

type ProtobufCodec struct {
}

func (*ProtobufCodec) MIME

func (*ProtobufCodec) MIME() string

func (*ProtobufCodec) Marshal

func (c *ProtobufCodec) Marshal(v interface{}) ([]byte, error)

func (*ProtobufCodec) MarshalTo

func (c *ProtobufCodec) MarshalTo(buf []byte, v interface{}) (int, error)

func (*ProtobufCodec) Size

func (c *ProtobufCodec) Size(v interface{}) int

func (*ProtobufCodec) Unmarshal

func (c *ProtobufCodec) Unmarshal(buf []byte, v interface{}) error

type Server

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

func NewServer

func NewServer() *Server

func (*Server) Handle

func (s *Server) Handle(p string, h http.Handler)

func (*Server) HandleHostname

func (s *Server) HandleHostname()

func (*Server) ListenAndServe

func (s *Server) ListenAndServe(addr string) error

func (*Server) Mount

func (s *Server) Mount(dir string, h http.Handler)

func (*Server) Serve

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

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context, d time.Duration) error

func (*Server) Stop

func (s *Server) Stop() error

func (*Server) Use

func (s *Server) Use(m ...func(http.Handler) http.Handler)

func (*Server) UseShutdownMiddleware

func (s *Server) UseShutdownMiddleware(code int, body []byte)

Directories

Path Synopsis
main.go template.go
main.go template.go
testservice
Package testservice is a generated protocol buffer package.
Package testservice is a generated protocol buffer package.
systest
api_v1
Package api_v1 is a generated protocol buffer package.
Package api_v1 is a generated protocol buffer package.
cmd

Jump to

Keyboard shortcuts

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