Documentation ¶
Overview ¶
Package localserver is a generated protocol buffer package.
Web exposes a backend server over gRPC.
It is generated from these files:
grpc.proto
It has these top-level messages:
Key Value KV OpResult
Index ¶
- func NewHTTP1Client(ca *CA) *http.Client
- func NewHTTP2Client(ca *CA) *http.Client
- func NewTLSConfig(ca *CA, certs ...*SignedCert) *tls.Config
- func NewTestHandler(respCode int) http.HandlerFunc
- func RegisterGRPCServer(s *grpc.Server, srv GRPCServer)
- type CA
- type CAOption
- type GRPCClient
- type GRPCServer
- type GRPCServerImpl
- func (i *GRPCServerImpl) Addr() string
- func (i *GRPCServerImpl) AddrPort() string
- func (i *GRPCServerImpl) Get(ctx context.Context, key *Key) (*Value, error)
- func (i *GRPCServerImpl) GetKVStream(key *Key, stream GRPC_GetKVStreamServer) error
- func (i *GRPCServerImpl) PutKVStream(stream GRPC_PutKVStreamServer) error
- func (i *GRPCServerImpl) ServeGRPC()
- func (i *GRPCServerImpl) Stop()
- type GRPC_GetKVStreamClient
- type GRPC_GetKVStreamServer
- type GRPC_PutKVStreamClient
- type GRPC_PutKVStreamServer
- type KV
- type Key
- type LocalServer
- type OpResult
- type Option
- type SignedCert
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewHTTP1Client ¶
NewHTTP1Client creates an http1 client that trusts our CA.
func NewHTTP2Client ¶
NewHTTP2Client creates an http2 client that trusts our CA.
func NewTLSConfig ¶
func NewTLSConfig(ca *CA, certs ...*SignedCert) *tls.Config
NewTLSConfig builds a *tls.Config from a CA and one or more signed certs.
func NewTestHandler ¶
func NewTestHandler(respCode int) http.HandlerFunc
NewTestHandler creates a handler that only writes a response code to test requests.
func RegisterGRPCServer ¶ added in v1.0.1
func RegisterGRPCServer(s *grpc.Server, srv GRPCServer)
Types ¶
type CA ¶
CA is a temporary certificate authority suitable for LocalServers.
func (*CA) CreateSignedCert ¶
func (ca *CA) CreateSignedCert(name string) (*SignedCert, error)
CreateSignedCert creates a signed certifictate.
type CAOption ¶
type CAOption func(*caConfig)
CAOption are options for a Certificate Authority.
func WithCommonName ¶
WithCommonName sets a common name on a CA.
func WithDNSNames ¶
WithDNSNames sets one or more supported DNS names on a CA. If you want to issue certs for a specfic DNS/SAN/host name, you must set them with this option.
func WithOrganization ¶
WithOrganization sets one or more organization names on a CA.
type GRPCClient ¶ added in v1.0.1
type GRPCClient interface { Get(ctx context.Context, in *Key, opts ...grpc.CallOption) (*Value, error) PutKVStream(ctx context.Context, opts ...grpc.CallOption) (GRPC_PutKVStreamClient, error) GetKVStream(ctx context.Context, in *Key, opts ...grpc.CallOption) (GRPC_GetKVStreamClient, error) }
func NewGRPCClient ¶ added in v1.0.1
func NewGRPCClient(cc *grpc.ClientConn) GRPCClient
func NewGRPCClientForServer ¶ added in v1.0.1
func NewGRPCClientForServer(ca *CA, addr string) (GRPCClient, error)
NewGRPCClientForServer ...
type GRPCServer ¶ added in v1.0.1
type GRPCServer interface { Get(context.Context, *Key) (*Value, error) PutKVStream(GRPC_PutKVStreamServer) error GetKVStream(*Key, GRPC_GetKVStreamServer) error }
type GRPCServerImpl ¶ added in v1.0.1
GRPCServerImpl ...
func NewGRPCServer ¶ added in v1.0.1
func NewGRPCServer(ca *CA, cert *SignedCert, authority string) (*GRPCServerImpl, error)
NewGRPCServer spins up a server pair on a random port. Inspect the Addr field on the returned server to see the port selected for the server. The authority parameter is the server hostname.
func (*GRPCServerImpl) Addr ¶ added in v1.0.1
func (i *GRPCServerImpl) Addr() string
Addr returns the full network address of the LocalServer's net.Listener.
func (*GRPCServerImpl) AddrPort ¶ added in v1.0.1
func (i *GRPCServerImpl) AddrPort() string
AddrPort returns the network port of the LocalServer's net.Listener.
func (*GRPCServerImpl) Get ¶ added in v1.0.1
Get is our test method for simple unary request-response.
func (*GRPCServerImpl) GetKVStream ¶ added in v1.0.1
func (i *GRPCServerImpl) GetKVStream(key *Key, stream GRPC_GetKVStreamServer) error
GetKVStream is our test method to stream from server to client.
func (*GRPCServerImpl) PutKVStream ¶ added in v1.0.1
func (i *GRPCServerImpl) PutKVStream(stream GRPC_PutKVStreamServer) error
PutKVStream is our test method to stream from client to server.
func (*GRPCServerImpl) ServeGRPC ¶ added in v1.0.1
func (i *GRPCServerImpl) ServeGRPC()
ServeGRPC starts a grpc server asyncronously.
func (*GRPCServerImpl) Stop ¶ added in v1.0.1
func (i *GRPCServerImpl) Stop()
Stop stops our grpc server.
type GRPC_GetKVStreamClient ¶ added in v1.0.1
type GRPC_GetKVStreamClient interface { Recv() (*KV, error) grpc.ClientStream }
type GRPC_GetKVStreamServer ¶ added in v1.0.1
type GRPC_GetKVStreamServer interface { Send(*KV) error grpc.ServerStream }
type GRPC_PutKVStreamClient ¶ added in v1.0.1
type GRPC_PutKVStreamServer ¶ added in v1.0.1
type KV ¶ added in v1.0.1
type KV struct { Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"` Value string `protobuf:"bytes,2,opt,name=value" json:"value,omitempty"` }
func (*KV) Descriptor ¶ added in v1.0.1
func (*KV) ProtoMessage ¶ added in v1.0.1
func (*KV) ProtoMessage()
type Key ¶ added in v1.0.1
type Key struct {
Key string `protobuf:"bytes,1,opt,name=key" json:"key,omitempty"`
}
func (*Key) Descriptor ¶ added in v1.0.1
func (*Key) ProtoMessage ¶ added in v1.0.1
func (*Key) ProtoMessage()
type LocalServer ¶
type LocalServer struct { TLS *tls.Config Srv *http.Server Lis net.Listener // contains filtered or unexported fields }
LocalServer is a server that can be configured to respond with a configurable handler. This is useful for testing.
func NewLocalServer ¶
func NewLocalServer(h http.HandlerFunc, cert *SignedCert, ca *CA, opts ...Option) *LocalServer
NewLocalServer builds a LocalServer.
func (*LocalServer) AddrPort ¶
func (ls *LocalServer) AddrPort() string
AddrPort returns the network address of the LocalServer's net.Listener.
func (*LocalServer) Debug ¶
func (ls *LocalServer) Debug() string
func (*LocalServer) StartHTTP1 ¶
func (ls *LocalServer) StartHTTP1()
StartHTTP1 starts a LocalServer as an HTTP1 server.
func (*LocalServer) StartHTTP2 ¶
func (ls *LocalServer) StartHTTP2()
StartHTTP2 starts a LocalServer as an HTTP2 server. We rely on Go's net/http package using HTTP2 by default, as long as the server uses TLS with the right protocol suite.
type OpResult ¶ added in v1.0.1
type OpResult struct {
ErrCode int64 `protobuf:"varint,1,opt,name=err_code,json=errCode" json:"err_code,omitempty"`
}
func (*OpResult) Descriptor ¶ added in v1.0.1
func (*OpResult) GetErrCode ¶ added in v1.0.1
func (*OpResult) ProtoMessage ¶ added in v1.0.1
func (*OpResult) ProtoMessage()
type SignedCert ¶
A SignedCert can be created by a CA.
type Value ¶ added in v1.0.1
type Value struct {
Value string `protobuf:"bytes,1,opt,name=value" json:"value,omitempty"`
}
func (*Value) Descriptor ¶ added in v1.0.1
func (*Value) ProtoMessage ¶ added in v1.0.1
func (*Value) ProtoMessage()