intercept

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2022 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Overview

Author: Paul Côté Last Change Author: Paul Côté Last Date Changed: 2022/09/20

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Author: Paul Côté Last Change Author: Paul Côté Last Date Changed: 2022/06/10

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Package intercept defines objects and related functions to monitor requests to shutdown the application

Index

Constants

View Source
const (
	ErrWaitingToStart  = bg.Error("waiting to start, RPC services not available")
	ErrDaemonLocked    = bg.Error("daemon locked, unlock it to enable full RPC access")
	ErrDaemonUnlocked  = bg.Error("daemon already unlocked, unlocker service is no longer available")
	ErrRPCStarting     = bg.Error("the RPC server is in the process of starting up, but not yet ready to accept calls")
	ErrInvalidRPCState = bg.Error("invalid RPC state")
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GrpcInterceptor

type GrpcInterceptor struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

GrpcInteceptor struct is a data structure with attributes relevant to creating the gRPC interceptor

func NewGrpcInterceptor

func NewGrpcInterceptor(log *zerolog.Logger, noMacaroons bool) *GrpcInterceptor

NewGrpcInterceptor instantiates a new GrpcInterceptor struct

func (*GrpcInterceptor) AddMacaroonService

func (i *GrpcInterceptor) AddMacaroonService(service *macaroons.Service)

Adds the macaroon service provided to GrpcInterceptor struct attributes

func (*GrpcInterceptor) AddPermission

func (i *GrpcInterceptor) AddPermission(method string, ops []bakery.Op) error

AddPermission adds a new macaroon rule for the given method

func (*GrpcInterceptor) AddPermissions

func (i *GrpcInterceptor) AddPermissions(perms map[string][]bakery.Op) error

AddPermissions adds the inputted permission to the permissionMap attribute of the GrpcInterceptor struct

func (*GrpcInterceptor) CreateGrpcOptions

func (i *GrpcInterceptor) CreateGrpcOptions() []grpc.ServerOption

CreateGrpcOptions creates a array of gRPC interceptors

func (*GrpcInterceptor) MacaroonStreamServerInterceptor

func (i *GrpcInterceptor) MacaroonStreamServerInterceptor() grpc.StreamServerInterceptor

MacaroonStreamServerInterceptor is a GRPC interceptor that checks whether the request is authorized by the included macaroons.

func (*GrpcInterceptor) MacaroonUnaryServerInterceptor

func (i *GrpcInterceptor) MacaroonUnaryServerInterceptor() grpc.UnaryServerInterceptor

MacaroonUnaryServerInterceptor is a GRPC interceptor that checks whether the request is authorized by the included macaroons.

func (*GrpcInterceptor) Permissions

func (i *GrpcInterceptor) Permissions() map[string][]bakery.Op

Permissions returns the current set of macaroon permissions

func (*GrpcInterceptor) SetDaemonLocked

func (i *GrpcInterceptor) SetDaemonLocked()

SetDaemonLocked changes the RPC state from waitingToStart to locked

func (*GrpcInterceptor) SetDaemonUnlocked

func (i *GrpcInterceptor) SetDaemonUnlocked()

SetDaemonUnlocked changes the RPC state from locked to unlocked

func (*GrpcInterceptor) SetRPCActive

func (i *GrpcInterceptor) SetRPCActive()

SetRPCActive changes the RPC state from unlocked to rpcActive

func (*GrpcInterceptor) SetWaitingToStart

func (i *GrpcInterceptor) SetWaitingToStart()

SetWaitingToStart changes the rRPC state to waitingToStart

type Interceptor

type Interceptor struct {
	Logger *zerolog.Logger
	// contains filtered or unexported fields
}

Interceptor is the object controlling application shutdown requests

func InitInterceptor

func InitInterceptor() (*Interceptor, error)

InitInterceptor initializes the shutdown and interrupt interceptor

func (*Interceptor) Close

func (i *Interceptor) Close() error

Close changes the atomic state variable for started

func (*Interceptor) RequestShutdown

func (interceptor *Interceptor) RequestShutdown()

RequestShutdown initiates a graceful shutdown from the application.

func (*Interceptor) ShutdownChannel

func (c *Interceptor) ShutdownChannel() <-chan struct{}

ShutdownChannel returns the channel that will be closed once the main interrupt handler has exited.

Jump to

Keyboard shortcuts

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