aviation

package module
v0.0.0-...-29e664c Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2020 License: Apache-2.0 Imports: 21 Imported by: 0

README

=======================================
``aviation`` -- gRPC Middleware Helpers
=======================================

Overview
--------

Aviation is a set of tools for building services, as a kind of
analogue for what `gimlet <https://github.com/deciduosity/gimlet>`_
does for REST services.

Goals
-----

- provide middleware to support common patterns including logging, recovery,
  middleware.

- support basic authentication mechanism for interoperability with
  gimlet services.

Limitations
-----------

- aviation does not provide client interceptors.

- aviation should not attempt to wrap gRPC in the way that gimlet
  wraps negroni and gorilla mux.

Development and Use
-------------------

Aviation is available under the terms of the Apache License (v2.)

Please see the `godoc for complete documentation of the API
<https://godoc.org/github.com/deciduosity/aviation>`_.

If you encounter an issue with Aviation or have a feature request please open
an issue in the github project.

There's a ``makefile`` which supports development operations: use the ``test``
and ``lint`` targets to validate code when making changes.

Documentation

Overview

Package avaiation is a collection of tools to support grpc middleware

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ChainStreamServer

func ChainStreamServer(interceptors ...grpc.StreamServerInterceptor) grpc.StreamServerInterceptor

ChainStreamServer creates a single interceptor out of a chain of many interceptors.

Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three. If you want to pass context between interceptors, use WrapServerStream.

Implementation from https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/chain.go

func ChainUnaryServer

func ChainUnaryServer(interceptors ...grpc.UnaryServerInterceptor) grpc.UnaryServerInterceptor

ChainUnaryServer creates a single interceptor out of a chain of many interceptors.

Execution is done in left-to-right order, including passing of context. For example ChainUnaryServer(one, two, three) will execute one before two before three, and three will see context changes of one and two.

Implementation from https://github.com/grpc-ecosystem/go-grpc-middleware/blob/master/chain.go

func Dial

func Dial(ctx context.Context, opts DialOptions) (*grpc.ClientConn, error)

Dial creates a client connection to a RPC service via gRPC.

func GetClientTLSConfig

func GetClientTLSConfig(ca, crt, key []byte) (*tls.Config, error)

GetClientTLSConfig creates a creates a client-side TLS configuration based on the given ca, cert, and key.

func GetClientTLSConfigFromFiles

func GetClientTLSConfigFromFiles(caFile, crtFile, keyFile string) (*tls.Config, error)

GetClientTLSConfigFromFiles creates a creates a client-side TLS configuration based on the given ca, cert, and key files.

func GetRequestID

func GetRequestID(ctx context.Context) int

GetRequestID returns the unique (monotonically increaseing) ID of the request since startup

func GetRequestStartAt

func GetRequestStartAt(ctx context.Context) time.Time

func GetUser

func GetUser(ctx context.Context) gimlet.User

GetUser returns the user attached to the request. The User object is nil when

func MakeCertificateUserValidationStreamInterceptor

func MakeCertificateUserValidationStreamInterceptor(um gimlet.UserManager) grpc.StreamServerInterceptor

Return a gRPC UnaryStreamInterceptor which checks the certifcate user's validity against the given user manager.

func MakeCertificateUserValidationUnaryInterceptor

func MakeCertificateUserValidationUnaryInterceptor(um gimlet.UserManager) grpc.UnaryServerInterceptor

Return a gRPC UnaryServerInterceptor which checks the certifcate user's validity against the given user manager.

func MakeGripStreamInterceptor

func MakeGripStreamInterceptor(logger grip.Journaler) grpc.StreamServerInterceptor

func MakeGripUnaryInterceptor

func MakeGripUnaryInterceptor(logger grip.Journaler) grpc.UnaryServerInterceptor

func MakeRetryStreamClientInterceptor

func MakeRetryStreamClientInterceptor(maxRetries int) grpc.StreamClientInterceptor

func MakeRetryUnaryClientInterceptor

func MakeRetryUnaryClientInterceptor(maxRetries int) grpc.UnaryClientInterceptor

func SetRequestID

func SetRequestID(ctx context.Context, id int) context.Context

SetRequesID attaches a request id to a context.

func SetRequestStartAt

func SetRequestStartAt(ctx context.Context, startAt time.Time) context.Context

func SetRequestUser

func SetRequestUser(ctx context.Context, u gimlet.User) context.Context

SetRequestUser adds a user to a context. This function is public to support teasing workflows.

Types

type DialOptions

type DialOptions struct {
	// Address is the RPC address to connect to.
	Address string
	// Retries specifies the number of times the client connection retries
	// an operation before failing.
	Retries int
	// TLSConf is the config for TLS authentication. If TLSConf is
	// specified, CAFile, CrtFile, and KeyFile are ignored. If neither
	// TLSFile nor the certificate files are specified, the connection is
	// created without TLS. (Optional)
	TLSConf *tls.Config
	// CAFile is the name of the file with the CA certificate for TLS. If
	// specified, CrtFile and KeyFile must also be specified. (Optional)
	CAFile string
	// CrtFile is the name of the file with the user certificate for TLS.
	// If specified, CAFile and KeyFile must also be specified. (Optional)
	CrtFile string
	// KeyFile is the name of the file with the key certificate for TLS. If
	// specified, CAFile and CrtFile must also be specified. (Optional)
	KeyFile string
}

DialOptions describes the options for creating a client connection to a RPC service via gRPC.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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