view

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 6, 2025 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstallViewHandler

func InstallViewHandler(viewManager *view.Manager, server Service, tracerProvider trace.TracerProvider)

func UnmarshalCommand

func UnmarshalCommand(raw []byte) (*protos.Command, error)

UnmarshalCommand unmarshal Command messages

Types

type AccessControlChecker

type AccessControlChecker struct {
	IdentityProvider IdentityProvider
	VerifierProvider VerifierProvider
}

func NewAccessControlChecker

func NewAccessControlChecker(identityProvider IdentityProvider, verifierProvider VerifierProvider) *AccessControlChecker

func (*AccessControlChecker) Check

type Identity

type Identity interface {
	Serialize() ([]byte, error)
}

Identity refers to the creator of a tx;

type IdentityProvider

type IdentityProvider interface {
	DefaultIdentity() view.Identity
	Admins() []view.Identity
	Clients() []view.Identity
}

type Marshaller

type Marshaller interface {
	MarshalCommandResponse(command []byte, responsePayload interface{}) (*protos2.SignedCommandResponse, error)
}

A Marshaller is responsible for marshaling and signing command responses.

type Metrics

type Metrics struct {
	RequestsReceived  metrics.Counter
	RequestsCompleted metrics.Counter
}

func NewMetrics

func NewMetrics(p metrics.Provider) *Metrics

type PolicyChecker

type PolicyChecker interface {
	Check(sc *protos2.SignedCommand, c *protos2.Command) error
}

A PolicyChecker is responsible for performing policy based access control checks related to view commands.

type Processor

type Processor func(ctx context.Context, command *protos2.Command) (interface{}, error)

type ResponseMarshaler

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

ResponseMarshaler produces SignedCommandResponse

func NewResponseMarshaler

func NewResponseMarshaler(hasher hash.Hasher, identityProvider IdentityProvider, sigService SignerProvider) (*ResponseMarshaler, error)

func (*ResponseMarshaler) MarshalCommandResponse

func (s *ResponseMarshaler) MarshalCommandResponse(command []byte, responsePayload interface{}) (*protos.SignedCommandResponse, error)

type Server added in v0.3.0

type Server struct {
	protos2.UnimplementedViewServiceServer
	Marshaller    Marshaller
	PolicyChecker PolicyChecker
	// contains filtered or unexported fields
}

Server is responsible for processing view commands.

func NewViewServiceServer

func NewViewServiceServer(marshaller Marshaller, policyChecker PolicyChecker, metrics *Metrics, tracerProvider trace.TracerProvider) (*Server, error)

func (*Server) MarshalErrorResponse added in v0.3.0

func (s *Server) MarshalErrorResponse(command []byte, e error) (*protos2.SignedCommandResponse, error)

func (*Server) ProcessCommand added in v0.3.0

func (s *Server) ProcessCommand(ctx context.Context, sc *protos2.SignedCommand) (cr *protos2.SignedCommandResponse, err error)

func (*Server) RegisterProcessor added in v0.3.0

func (s *Server) RegisterProcessor(typ reflect.Type, p Processor)

func (*Server) RegisterStreamer added in v0.3.0

func (s *Server) RegisterStreamer(typ reflect.Type, streamer Streamer)

func (*Server) StreamCommand added in v0.3.0

func (s *Server) StreamCommand(server protos2.ViewService_StreamCommandServer) error

func (*Server) ValidateHeader added in v0.3.0

func (s *Server) ValidateHeader(header *protos2.Header) error

type Service

type Service interface {
	protos2.ViewServiceServer

	RegisterProcessor(typ reflect.Type, p Processor)
	RegisterStreamer(typ reflect.Type, streamer Streamer)
}

func GetService

func GetService(sp view.ServiceProvider) Service

type SignerProvider added in v0.4.0

type SignerProvider interface {
	GetSigner(identity view2.Identity) (view.Signer, error)
}

type SigningIdentity

type SigningIdentity interface {
	Identity //extends Identity

	Sign(msg []byte) ([]byte, error)
}

SigningIdentity defines the functions necessary to sign an array of bytes; it is needed to sign the commands

type Stream added in v0.3.0

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

func (*Stream) Recv added in v0.3.0

func (c *Stream) Recv(m interface{}) error

func (*Stream) RecvProtoMsg added in v0.3.0

func (c *Stream) RecvProtoMsg(m interface{}) error

func (*Stream) Send added in v0.3.0

func (c *Stream) Send(m interface{}) error

func (*Stream) SendProtoMsg added in v0.3.0

func (c *Stream) SendProtoMsg(m interface{}) error

type Streamer

type Streamer func(sc *protos2.SignedCommand, command *protos2.Command, commandServer protos2.ViewService_StreamCommandServer, marshaler Marshaller) error

type TimeFunc

type TimeFunc func() time.Time

type VerifierProvider

type VerifierProvider interface {
	GetVerifier(identity view.Identity) (view2.Verifier, error)
}

type YesPolicyChecker

type YesPolicyChecker struct {
}

func (YesPolicyChecker) Check

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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