view

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 56

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CommService added in v0.3.0

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

CommService provides endpoint-related services

func GetCommService added in v0.3.0

func GetCommService(sp ServiceProvider) *CommService

GetCommService returns an instance of the endpoint service. It panics, if no instance is found.

func (*CommService) Addresses added in v0.3.0

func (c *CommService) Addresses(id view.Identity) ([]string, error)

type ConfigService

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

ConfigService models a configuration registry

func GetConfigService

func GetConfigService(sp ServiceProvider) *ConfigService

GetConfigService returns an instance of the config service. It panics, if no instance is found.

func (*ConfigService) ConfigFileUsed

func (c *ConfigService) ConfigFileUsed() string

ConfigFileUsed returns the file used to populate the config registry

func (*ConfigService) GetBool

func (c *ConfigService) GetBool(key string) bool

GetBool returns the value associated with the key asa boolean

func (*ConfigService) GetDuration

func (c *ConfigService) GetDuration(key string) time.Duration

GetDuration returns the value associated with the key as a duration

func (*ConfigService) GetInt

func (c *ConfigService) GetInt(path string) int

GetInt returns the value associated with the key as an integer

func (*ConfigService) GetPath

func (c *ConfigService) GetPath(key string) string

GetPath allows configuration strings that specify a (config-file) relative path

func (*ConfigService) GetString

func (c *ConfigService) GetString(key string) string

GetString returns the value associated with the key as a string

func (*ConfigService) GetStringSlice

func (c *ConfigService) GetStringSlice(key string) []string

GetStringSlice returns the value associated with the key as a slice of strings

func (*ConfigService) IsSet

func (c *ConfigService) IsSet(key string) bool

IsSet checks to see if the key has been set in any of the data locations

func (*ConfigService) TranslatePath

func (c *ConfigService) TranslatePath(path string) string

TranslatePath translates the passed path relative to the config path

func (*ConfigService) UnmarshalKey

func (c *ConfigService) UnmarshalKey(key string, rawVal interface{}) error

UnmarshalKey takes a single key and unmarshals it into a Struct

type Context

type Context struct {
	view.Context
}

Context gives a view information about the environment in which it is in execution

type EndpointService

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

EndpointService provides endpoint-related services

func GetEndpointService

func GetEndpointService(sp ServiceProvider) *EndpointService

GetEndpointService returns an instance of the endpoint service. It panics, if no instance is found.

func (*EndpointService) AddPKIResolver

func (e *EndpointService) AddPKIResolver(pkiResolver PKIResolver) error

AddPKIResolver add a new PKI resolver

func (*EndpointService) AddResolver

func (e *EndpointService) AddResolver(name string, domain string, addresses map[string]string, aliases []string, id []byte) (view.Identity, error)

AddResolver adds a resolver for tha passed parameters. The passed id can be retrieved by using the passed name in a call to GetIdentity method. The addresses can be retrieved by passing the identity in a call to Resolve. If a resolver is already bound to the passed name, then the passed identity is linked to the already existing identity. The already existing identity is returned

func (*EndpointService) Bind

func (e *EndpointService) Bind(longTerm view.Identity, ephemeral view.Identity) error

Bind associated a 'long term' identity to an 'ephemeral' one. In more general terms, Bind binds any identity to another.

func (*EndpointService) Endpoint

func (e *EndpointService) Endpoint(party view.Identity) (map[PortName]string, error)

Endpoint returns the endpoint of the passed identity

func (*EndpointService) GetIdentity

func (e *EndpointService) GetIdentity(label string, pkiID []byte) (view.Identity, error)

GetIdentity returns an identity bound to either the passed label or public-key identifier.

func (*EndpointService) IsBoundTo

func (e *EndpointService) IsBoundTo(a view.Identity, b view.Identity) bool

IsBoundTo returns true if b was bound to a

func (*EndpointService) Resolve

func (e *EndpointService) Resolve(party view.Identity) (view.Identity, map[PortName]string, []byte, error)

Resolve returns the endpoints of the passed identity. If the passed identity does not have any endpoint set, the service checks if the passed identity is bound to another identity that is returned together with its endpoints and public-key identifier.

func (*EndpointService) ResolveIdentities

func (e *EndpointService) ResolveIdentities(endpoints ...string) ([]view.Identity, error)

type Factory

type Factory interface {
	// NewView returns an instance of the View interface build using the passed argument.
	NewView(in []byte) (view.View, error)
}

Factory is used to create instances of the View interface

type Identity

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

func (*Identity) Serialize

func (i *Identity) Serialize() ([]byte, error)

Serialize returns the byte representation of this identity

func (*Identity) Verify

func (i *Identity) Verify(message []byte, signature []byte) error

Verify verifies the signature over the passed message.

type IdentityProvider

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

IdentityProvider provides identity services

func GetIdentityProvider

func GetIdentityProvider(sp ServiceProvider) *IdentityProvider

GetIdentityProvider returns an instance of the identity provider. It panics, if no instance is found.

func (*IdentityProvider) Admins

func (i *IdentityProvider) Admins() []view.Identity

Admins returns the identities of the administrators

func (*IdentityProvider) Clients

func (i *IdentityProvider) Clients() []view.Identity

Clients returns the identities of the clients that can invoke views on this node

func (*IdentityProvider) DefaultIdentity

func (i *IdentityProvider) DefaultIdentity() view.Identity

DefaultIdentity returns the default identity

func (*IdentityProvider) Identity

func (i *IdentityProvider) Identity(label string) view.Identity

Identity returns the identity bound to the passed label

type Manager

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

Manager manages the lifecycle of views and contexts

func GetManager

func GetManager(sp ServiceProvider) *Manager

GetManager returns an instance of the view manager. It panics, if no instance is found.

func (*Manager) Context

func (m *Manager) Context(contextID string) (*Context, error)

Context returns the context associated to the passed id, an error if not context is found.

func (*Manager) InitiateContext

func (m *Manager) InitiateContext(view View) (*Context, error)

InitiateContext initiates a new context for the passed view

func (*Manager) InitiateContextWithIdentityAndID added in v0.2.0

func (m *Manager) InitiateContextWithIdentityAndID(view View, id view.Identity, contextID string) (view.Context, error)

InitiateContextWithIdentityAndID initiates

func (*Manager) InitiateView

func (m *Manager) InitiateView(view View) (interface{}, error)

InitiateView invokes the passed view and returns the result produced by that view

func (*Manager) NewView

func (m *Manager) NewView(id string, in []byte) (View, error)

NewView returns a new instance of the view identified by the passed id and on input. Have a look at Registry to learn how to register view factories and responders

type PKIResolver

type PKIResolver interface {
	// GetPKIidOfCert returns the id of the public key contained in the passed identity
	GetPKIidOfCert(peerIdentity view.Identity) []byte
}

PKIResolver extracts public key ids from identities

type PortName

type PortName string

PortName is the type variable for the socket ports

const (
	// ListenPort is the port at which the FSC node might listen for some service
	ListenPort PortName = "Listen"
	// ViewPort is the port on which the View Service Server respond
	ViewPort PortName = "View"
	// P2PPort is the port on which the P2P Communication Layer respond
	P2PPort PortName = "P2P"
)

type Registry

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

Registry keeps track of the available view and view factories

func GetRegistry

func GetRegistry(sp ServiceProvider) *Registry

GetRegistry returns an instance of the view registry. It panics, if no instance is found.

func (*Registry) GetIdentifier

func (r *Registry) GetIdentifier(f View) string

GetIdentifier returns the identifier of the passed view

func (*Registry) GetResponder

func (r *Registry) GetResponder(initiatedBy interface{}) (View, error)

GetResponder returns the responder for the passed initiator.

func (*Registry) RegisterFactory

func (r *Registry) RegisterFactory(id string, factory Factory) error

RegisterFactory binds an id to a View Factory

func (*Registry) RegisterResponder

func (r *Registry) RegisterResponder(responder View, initiatedBy interface{}) error

RegisterResponder binds a responder to an initiator. The responder is the view that will be called when the initiator (initiatedBy) contacts the FSC node where this RegisterResponder is invoked. The argument initiatedBy can be a view or a view identifier. If a view is passed, its identifier is computed and used to register the responder.

func (*Registry) RegisterResponderWithIdentity

func (r *Registry) RegisterResponderWithIdentity(responder View, id view.Identity, initiatedBy interface{}) error

RegisterResponderWithIdentity binds the pair <responder, id> to an initiator. The responder is the view that will be called when the initiator (initiatedBy) contacts the FSC node where this RegisterResponderWithIdentity is invoked. The argument initiatedBy can be a view or a view identifier. If a view is passed, its identifier is computed and used to register the responder.

type ServiceProvider

type ServiceProvider interface {
	// GetService returns an instance of the given type
	GetService(v interface{}) (interface{}, error)
}

ServiceProvider is used to return instances of a given type

type SigService

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

SigService models a repository of sign and verify keys.

func GetSigService

func GetSigService(sp ServiceProvider) *SigService

GetSigService returns an instance of the sig service. It panics, if no instance is found.

func (*SigService) GetAuditInfo

func (s *SigService) GetAuditInfo(identity view.Identity) ([]byte, error)

GetAuditInfo returns the audit info associated to the passed identity, nil if not found

func (*SigService) GetSigner

func (s *SigService) GetSigner(identity view.Identity) (Signer, error)

GetSigner returns the signer bound to the passed identity

func (*SigService) GetSigningIdentity

func (s *SigService) GetSigningIdentity(identity view.Identity) (*SigningIdentity, error)

GetSigningIdentity returns the signer identity bound to the passed identity

func (*SigService) GetVerifier

func (s *SigService) GetVerifier(identity view.Identity) (Verifier, error)

GetVerifier returns the verifier bound to the passed identity

func (*SigService) IsMe

func (s *SigService) IsMe(identity view.Identity) bool

IsMe returns true if a signer was ever registered for the passed identity

func (*SigService) RegisterAuditInfo

func (s *SigService) RegisterAuditInfo(identity view.Identity, info []byte) error

RegisterAuditInfo binds the passed audit info to the passed identity

func (*SigService) RegisterSigner

func (s *SigService) RegisterSigner(identity view.Identity, signer Signer, verifier Verifier) error

RegisterSigner binds the passed identity to the passed signer and verifier

func (*SigService) RegisterVerifier

func (s *SigService) RegisterVerifier(identity view.Identity, verifier Verifier) error

RegisterVerifier binds the passed identity to the passed verifier

type Signer

type Signer interface {
	// Sign signs message bytes and returns the signature or an error on failure.
	Sign(message []byte) ([]byte, error)
}

Signer is an interface which wraps the Sign method.

type SigningIdentity

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

SigningIdentity models an identity that can sign, verify messages and whose public side can be serialized

func (*SigningIdentity) GetPublicVersion

func (s *SigningIdentity) GetPublicVersion() *Identity

func (*SigningIdentity) Serialize

func (s *SigningIdentity) Serialize() ([]byte, error)

Serialize returns the byte representation of the public side of this identity

func (*SigningIdentity) Sign

func (s *SigningIdentity) Sign(message []byte) ([]byte, error)

Sign signs message bytes and returns the signature or an error on failure.

func (*SigningIdentity) Verify

func (s *SigningIdentity) Verify(message []byte, signature []byte) error

Verify verifies the signature over the passed message.

type Verifier

type Verifier interface {
	// Verify verifies the signature over the passed message.
	Verify(message, sigma []byte) error
}

Verifier is an interface which wraps the Verify method.

type View

type View interface {
	// Call invokes the View on input the passed argument.
	// It returns a result and error in case of failure.
	Call(context view.Context) (interface{}, error)
}

View wraps a callable function.

Directories

Path Synopsis
core
id
id/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
manager/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
sig
mock
Code generated by counterfeiter.
Code generated by counterfeiter.
sdk
services
db
db/driver/badger/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
db/driver/unversioned/mocks
Code generated by counterfeiter.
Code generated by counterfeiter.
events/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
flogging/httpadmin/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
flogging/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
grpc/metricsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
kms
kvs
kvs/mock
Code generated by counterfeiter.
Code generated by counterfeiter.
metrics/operations/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
server/web/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
server/web/middleware/fakes
Code generated by counterfeiter.
Code generated by counterfeiter.
server/web/mocks
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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