rpc

package
v0.0.0-...-02c76fb Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: Apache-2.0 Imports: 38 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// JWTLifetime is the acceptable lifetime of an issued JWT token
	JWTLifetime = 30 * time.Second

	// JWTAlg is the signing algorithm used for signing and verification
	JWTAlg = "HS512"
)

Variables

This section is empty.

Functions

func IsClosedNetworkConnErr

func IsClosedNetworkConnErr(err error) bool

IsClosedNetworkConnErr detects if an error is the use of a close network connection

func NewExecutorClient

func NewExecutorClient(ctx context.Context, addr string, security *Security) (pb.ExecutorClient, error)

NewExecutorClient returns a client for a server that implements Executor

Types

type GrapherClient

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

GrapherClient is a wrapper around a pb.GrapherClient

func NewGrapherClient

func NewGrapherClient(ctx context.Context, addr string, security *Security) (*GrapherClient, error)

NewGrapherClient returns a client for a server that implements Executor

func (*GrapherClient) Graph

func (gc *GrapherClient) Graph(ctx context.Context, loc *pb.LoadRequest, opts ...grpc.CallOption) (*graph.Graph, error)

Graph gets the graph from the remote side

type InfoClient

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

InfoClient is a wrapper around a pb.InfoClient

func NewInfoClient

func NewInfoClient(ctx context.Context, addr string, security *Security) (*InfoClient, error)

NewInfoClient returns a client for a server that implements Info

func (*InfoClient) Ping

func (i *InfoClient) Ping(ctx context.Context) error

Ping gets a ping response from the server

type JWTAuth

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

JWTAuth does authentication between client and server

func NewJWTAuth

func NewJWTAuth(token string) *JWTAuth

NewJWTAuth initializes a new JWTAuth from the token

func (*JWTAuth) GetRequestMetadata

func (j *JWTAuth) GetRequestMetadata(ctx context.Context, uri ...string) (map[string]string, error)

GetRequestMetadata gets the current request metadata

func (*JWTAuth) New

func (j *JWTAuth) New() (string, error)

New creates a signed token

func (*JWTAuth) Protect

func (j *JWTAuth) Protect(next http.Handler) http.Handler

Protect checks requests for a valid token

func (*JWTAuth) RequireTransportSecurity

func (j *JWTAuth) RequireTransportSecurity() bool

RequireTransportSecurity indicates whether JWT requires transport security (it does not)

func (*JWTAuth) StreamInterceptor

func (j *JWTAuth) StreamInterceptor(srv interface{}, stream grpc.ServerStream, info *grpc.StreamServerInfo, handler grpc.StreamHandler) error

StreamInterceptor implements StreamServerInterceptor to use in a middleware capacity

func (*JWTAuth) UnaryInterceptor

func (j *JWTAuth) UnaryInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error)

UnaryInterceptor implements UnaryServerInterceptor to use in a middleware capacity

func (*JWTAuth) Verify

func (j *JWTAuth) Verify(material string) error

Verify a generated token

func (*JWTAuth) VerifyContext

func (j *JWTAuth) VerifyContext(ctx context.Context) error

VerifyContext verifies a token in context metadata

type Security

type Security struct {
	Token string

	UseSSL   bool
	CAFile   string
	CertFile string // server only
	KeyFile  string // server only
}

Security configuration for

func (*Security) Client

func (s *Security) Client() (out []grpc.DialOption, err error)

Client returns a dial option for clients

func (*Security) Server

func (s *Security) Server() (out []grpc.ServerOption)

Server return a server option with the certificate credentials

func (*Security) TLSConfig

func (s *Security) TLSConfig() (*tls.Config, error)

TLSConfig gets a TLS Config from this Security

func (*Security) WrapListener

func (s *Security) WrapListener(lis net.Listener) (net.Listener, error)

WrapListener wraps a listener in a tls.Listener

type Server

type Server struct {
	// Security
	Security *Security

	// Serving
	ResourceRoot         string
	EnableBinaryDownload bool
}

Server represents the configuration for a Converge RPC server

func (*Server) Listen

func (s *Server) Listen(ctx context.Context, addr *url.URL) error

Listen on the given address for all server-related duties

Directories

Path Synopsis
pb
Package pb is a generated protocol buffer package.
Package pb is a generated protocol buffer package.

Jump to

Keyboard shortcuts

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