server

package
v0.0.5 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MemLimits

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

MemLimits structure contains memory limit levels to manage GC

func MakeMemLimits

func MakeMemLimits(limit uint64, reset, soft, back, frag float64) (MemLimits, error)

MakeMemLimits fills MemLimits structure with given parameters

type Option

type Option func(*options)

Option configures how we set up PDP server.

func WithAutoResponseSize

func WithAutoResponseSize(b bool) Option

WithAutoResponseSize creates an options which makes server automatically allocate response buffer. If the options isn't set server uses default fixed buffer size which is 10KB.

func WithControlAt

func WithControlAt(addr string) Option

WithControlAt returns a Option which sets control endpoint

func WithGRPCOptions added in v0.0.3

func WithGRPCOptions(opt ...grpc.ServerOption) Option

WithServerOption specifies gRPC Server Options

func WithHealthAt

func WithHealthAt(addr string) Option

WithHealthAt returns a Option which sets healthcheck endpoint

func WithLogger

func WithLogger(logger *log.Logger) Option

WithLogger returns a Option which sets logger

func WithMaxGRPCStreams

func WithMaxGRPCStreams(limit uint32) Option

WithMaxGRPCStreams returns a Option which sets maximum gRPC streams count

func WithMaxResponseSize

func WithMaxResponseSize(size uint32) Option

WithMaxResponseSize creates an option which limits response size in bytes. Default is 10KB. In case if a response doesn't fit the constraint, PDP puts error message to response which indicates this fact. Buffer should be at least pdp.MinResponseSize long to accept the error.

func WithMemLimits

func WithMemLimits(limits MemLimits) Option

WithMemLimits returns a Option which sets memory limits

func WithMemProfDumping

func WithMemProfDumping(path string, numGC uint32, delay time.Duration) Option

WithMemProfDumping returns a Option to enables memory profile dumps. Path points to a directory for memory profile files. File name is "mem-NNNNNNNNN.pprof" where NNNNNNNNN is value of runtime.MemStats.NumGC after which the profile is stored.Dumps are created at each numGC after first dump (negative or zero value disables dumping). If delay is above zero first dump is taken with the delay after request service port has been opened.

func WithMemStatsLogging

func WithMemStatsLogging(path string, interval time.Duration) Option

WithMemStatsLogging returns a Option which enables regular runtime.MemStats logging. Path points to file where stats are logged as sequence of JSON objects splitted by new line. Each JSON object contains timestamp and output of runtime.ReadMemStats taken with given interval. Zero interval logs MemStats with minimum and maximum Alloc value between NumGC changes but not more than once a 100 ms. Negative interval disables logging.

func WithPolicyParser

func WithPolicyParser(parser ast.Parser) Option

WithPolicyParser returns a Option which sets policy parser

func WithProfilerAt

func WithProfilerAt(addr string) Option

WithProfilerAt returns a Option which sets profiler endpoint

func WithServiceAt

func WithServiceAt(addr string) Option

WithServiceAt returns a Option which sets service endpoint

func WithStorageAt

func WithStorageAt(addr string) Option

WithStorageAt returns a Option which sets storage endpoint

func WithTracingAt

func WithTracingAt(addr string) Option

WithTracingAt returns a Option which sets tracing endpoint

func WithValidatePostHook added in v0.0.2

func WithValidatePostHook(f ValidatePostHookFn) Option

WithValidatePostHook calls the passed func at the end of Validate()

func WithValidatePreHook added in v0.0.2

func WithValidatePreHook(f ValidatePreHookFn) Option

WithValidatePreHook calls the passed func at the start of Validate()

type Server

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

Server structure is PDP server object

func NewServer

func NewServer(opts ...Option) *Server

NewServer returns new Server instance

func (*Server) Apply

func (s *Server) Apply(ctx context.Context, in *pb.Update) (*pb.Response, error)

Apply is a server handler for gRPC call It applies data previously saved in PDP

func (*Server) GRPCServer added in v0.0.3

func (s *Server) GRPCServer() *grpc.Server

GRPCServer expose the underlying gRPC Server

func (*Server) InitializeSelectors

func (s *Server) InitializeSelectors()

InitializeSelectors initialize all registered selectors that are enabled

func (*Server) LoadContent

func (s *Server) LoadContent(paths []string) error

LoadContent loads content from files

func (*Server) LoadPolicies

func (s *Server) LoadPolicies(path string) error

LoadPolicies loads policies from file

func (*Server) NewValidationStream

func (s *Server) NewValidationStream(stream pb.PDP_NewValidationStreamServer) error

NewValidationStream is a server handler for gRPC call It creates new gRPC stream and handles PDP decision requests using it

func (*Server) NotifyReady

func (s *Server) NotifyReady(ctx context.Context, m *pb.Empty) (*pb.Response, error)

NotifyReady is a server handler for gRPC call It starts handling decision requests

func (*Server) ReadContent

func (s *Server) ReadContent(readers ...io.Reader) error

ReadContent reads content with using io.Reader instances

func (*Server) ReadPolicies

func (s *Server) ReadPolicies(r io.Reader) error

ReadPolicies reads policies with using io.Reader instance

func (*Server) Request

func (s *Server) Request(ctx context.Context, in *pb.Item) (*pb.Response, error)

Request is a server handler for gRPC call It serves PAP control requests

func (*Server) Serve

func (s *Server) Serve() error

Serve starts PDP server service

func (*Server) Stop

func (s *Server) Stop() error

Stop stops PDP server service

func (*Server) Upload

func (s *Server) Upload(stream pb.PDPControl_UploadServer) error

Upload is a server handler for gRPC call It uploads data from PAP and save it to PDP

func (*Server) Validate

func (s *Server) Validate(ctx context.Context, in *pb.Msg) (*pb.Msg, error)

Validate is a server handler for gRPC call It handles PDP decision requests Return variables are named, so they can be passed to validate hooks.

type ValidatePostHookFn added in v0.0.2

type ValidatePostHookFn func(ctx context.Context, msg *pb.Msg, err error)

ValidatePostHookFn is called when passed to WithValidatePostHook

type ValidatePreHookFn added in v0.0.2

type ValidatePreHookFn func(ctx context.Context) context.Context

ValidatePreHookFn is called when passed to WithValidatePreHook

Jump to

Keyboard shortcuts

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