Documentation ΒΆ
Overview ΒΆ
* * Copyright 2017 gRPC authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. *
Package GOAT (gRPC Over Any Transport) is a gRPC client and server implementation which runs over any transport which implements RpcReadWriter.
The idea is that gRPC requests and responses are serialised into a wrapper protobuf (wrapped.Rpc).
Index ΒΆ
- type ClientConn
- type ClientDisconnect
- type Demux
- type DialOption
- type GoatOverHttp
- type GoatOverHttpOption
- type NewConnection
- type OnConnect
- type Proxy
- type Rpc
- type RpcHeader
- type RpcIntercepter
- type RpcReadWriter
- type Server
- type ServerOption
- func ChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) ServerOption
- func ChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) ServerOption
- func StreamInterceptor(i grpc.StreamServerInterceptor) ServerOption
- func UnaryInterceptor(i grpc.UnaryServerInterceptor) ServerOption
- type SourceToAddress
Constants ΒΆ
This section is empty.
Variables ΒΆ
This section is empty.
Functions ΒΆ
This section is empty.
Types ΒΆ
type ClientConn ΒΆ
type ClientConn struct {
// contains filtered or unexported fields
}
func NewClientConn ΒΆ
func NewClientConn(conn RpcReadWriter, source, dest string, opts ...DialOption) *ClientConn
func (*ClientConn) Invoke ΒΆ
func (cc *ClientConn) Invoke( ctx context.Context, method string, args interface{}, reply interface{}, opts ...grpc.CallOption, ) error
Invoke performs a unary RPC and returns after the response is received into reply.
func (*ClientConn) NewStream ΒΆ
func (cc *ClientConn) NewStream( ctx context.Context, desc *grpc.StreamDesc, method string, opts ...grpc.CallOption, ) (grpc.ClientStream, error)
NewStream begins a streaming RPC.
type ClientDisconnect ΒΆ
type Demux ΒΆ
type Demux struct {
// contains filtered or unexported fields
}
Wraps a Goat Server, demultiplexing IO.
func NewDemux ΒΆ
func NewDemux( ctx context.Context, rw RpcReadWriter, demuxOn func(*Rpc) string, onNewConnection func(RpcReadWriter), ) *Demux
NewDemux returns a new Demux which demultiplexex RPCs from the given |rw| into |onNewConnection| based the identity returned from |demuxOn|.
type DialOption ΒΆ
type DialOption interface {
// contains filtered or unexported methods
}
DialOption is an option used when constructing a NewClientConn.
func WithStreamInterceptor ΒΆ
func WithStreamInterceptor(i grpc.StreamClientInterceptor) DialOption
WithStreamInterceptor returns a DialOption that specifies the interceptor for streaming RPCs.
WARNING: the interceptor will receive a nil *grpc.ClientConn. See pkg doc.
func WithUnaryInterceptor ΒΆ
func WithUnaryInterceptor(i grpc.UnaryClientInterceptor) DialOption
WithUnaryInterceptor returns a DialOption that specifies the interceptor for unary RPCs.
WARNING: the interceptor will receive a nil *grpc.ClientConn. See pkg doc.
type GoatOverHttp ΒΆ
type GoatOverHttp struct {
// contains filtered or unexported fields
}
GoatOverHttp manages GOAT connections over HTTP 1.0, yielding a new HTTPRpcReadWriter whenever it receives an Rpc from a new source (via ServeHTTP) or when prompted to establish a NewConnection.
func NewGoatOverHttp ΒΆ
func NewGoatOverHttp( onConnect OnConnect, sourceToAddress SourceToAddress, opts ...GoatOverHttpOption, ) *GoatOverHttp
func (*GoatOverHttp) Cancel ΒΆ
func (goh *GoatOverHttp) Cancel()
func (*GoatOverHttp) NewConnection ΒΆ
func (goh *GoatOverHttp) NewConnection(destination string) RpcReadWriter
func (*GoatOverHttp) ServeHTTP ΒΆ
func (goh *GoatOverHttp) ServeHTTP(w http.ResponseWriter, r *http.Request)
type GoatOverHttpOption ΒΆ
type GoatOverHttpOption interface {
// contains filtered or unexported methods
}
func WithClock ΒΆ
func WithClock(cl clock.Clock) GoatOverHttpOption
WithClock sets the clock of the GoatOverHttp.
func WithConnectionCleanupInterval ΒΆ
func WithConnectionCleanupInterval(i time.Duration) GoatOverHttpOption
WithConnectionCleanupInterval sets the interval that the GoatOverHttp will wait between firings of the connection cleanup routine, which will close any stale connections.
func WithConnectionTimeout ΒΆ
func WithConnectionTimeout(t time.Duration) GoatOverHttpOption
WithConnectionTimeout sets the duration after which the GoatOverHttp will consider a given connection as stale and in need of being closed.
type NewConnection ΒΆ
type NewConnection func(id string) (RpcReadWriter, error)
type OnConnect ΒΆ
type OnConnect func(id string, rw RpcReadWriter)
OnConnect can be called by the GoatOverHttp to indicate that a new client has connected.
type Proxy ΒΆ
type Proxy struct {
// contains filtered or unexported fields
}
func NewProxy ΒΆ
func NewProxy( ctx context.Context, id string, newConnection NewConnection, rpcIntercepter RpcIntercepter, onClientDisconnect ClientDisconnect, ) *Proxy
func (*Proxy) AddClient ΒΆ
func (p *Proxy) AddClient(id string, conn RpcReadWriter)
type Rpc ΒΆ
Rpc is the fundamental type in Goat: the generic protobuf structure into which all goat messages are serialised.
type RpcHeader ΒΆ
type RpcHeader = proto.RequestHeader
RpcHeader represents the header of a Goat Rpc.
type RpcIntercepter ΒΆ
type RpcIntercepter func(hdr *goatorepo.RequestHeader) error
Is free to modify the passed in header, e.g. changing the Destination. If an error is returned, the RPC is dropped.
type RpcReadWriter ΒΆ
type RpcReadWriter = types.RpcReadWriter
RpcReadWriter is the generic interface used by Goat's client and servers. It utilises the wrapped.Rpc protobuf format for generically wrapping gRPC calls and their metadata.
func NewGoatOverChannel ΒΆ
func NewGoatOverChannel(inQ chan *Rpc, outQ chan *Rpc) RpcReadWriter
NewGoatOverChannel turns an input and an output channel into an RpcReadWriter.
func NewGoatOverWebsocket ΒΆ
func NewGoatOverWebsocket(ws *websocket.Conn) RpcReadWriter
type Server ΒΆ
type Server struct {
// contains filtered or unexported fields
}
func NewServer ΒΆ
func NewServer(id string, opts ...ServerOption) *Server
func (*Server) RegisterService ΒΆ
func (s *Server) RegisterService(sd *grpc.ServiceDesc, ss interface{})
grpc.ServiceRegistrar
type ServerOption ΒΆ
type ServerOption interface {
// contains filtered or unexported methods
}
ServerOption is an option used when constructing a NewServer.
func ChainStreamInterceptor ΒΆ added in v0.1.2
func ChainStreamInterceptor(interceptors ...grpc.StreamServerInterceptor) ServerOption
Same as grpc.ChainStreamInterceptor()
func ChainUnaryInterceptor ΒΆ added in v0.1.2
func ChainUnaryInterceptor(interceptors ...grpc.UnaryServerInterceptor) ServerOption
Same as grpc.ChainUnaryInterceptor()
func StreamInterceptor ΒΆ
func StreamInterceptor(i grpc.StreamServerInterceptor) ServerOption
StreamInterceptor returns a ServerOption that sets the StreamServerInterceptor for the server. Only one stream interceptor can be installed.
func UnaryInterceptor ΒΆ
func UnaryInterceptor(i grpc.UnaryServerInterceptor) ServerOption
UnaryInterceptor returns a ServerOption that sets the UnaryServerInterceptor for the server. Only one unary interceptor can be installed. The construction of multiple interceptors (e.g., chaining) can be implemented at the caller.
type SourceToAddress ΒΆ
SourceToAddress maps an Rpc source into an addressable entity.