Documentation ¶
Index ¶
- Variables
- func FromSignatureContext(ctx context.Context) (string, string, error)
- func NewExpBackoff(timeout time.Duration) *cbackoff.ExponentialBackOff
- func NewFindRequest(peerID, orgID ecid.ID, key id.ID, nPeers uint) *api.FindRequest
- func NewGetRequest(peerID, orgID ecid.ID, key id.ID) *api.GetRequest
- func NewIncomingSignatureContext(ctx context.Context, signedJWT, orgSignedJWT string) context.Context
- func NewIntroduceRequest(peerID, orgID ecid.ID, apiSelf *api.PeerAddress, nPeers uint) *api.IntroduceRequest
- func NewPutRequest(peerID, orgID ecid.ID, key id.ID, value *api.Document) *api.PutRequest
- func NewRequestMetadata(peerID, orgID ecid.ID) *api.RequestMetadata
- func NewRetryFinder(inner api.Finder, timeout time.Duration) api.Finder
- func NewRetryGetter(cb GetterBalancer, valueOnly bool, timeout time.Duration) api.Getter
- func NewRetryPutter(cb PutterBalancer, timeout time.Duration) api.Putter
- func NewRetryStorer(inner api.Storer, timeout time.Duration) api.Storer
- func NewRetryVerifier(inner api.Verifier, timeout time.Duration) api.Verifier
- func NewSignatureContext(ctx context.Context, signedJWT, orgSignedJWT string) context.Context
- func NewSignedContext(signer, orgSigner Signer, request proto.Message) (context.Context, error)
- func NewSignedTimeoutContext(signer, orgSigner Signer, request proto.Message, timeout time.Duration) (context.Context, context.CancelFunc, error)
- func NewStoreRequest(peerID, orgID ecid.ID, key id.ID, value *api.Document) *api.StoreRequest
- func NewSubscribeRequest(peerID, orgID ecid.ID, subscription *api.Subscription) *api.SubscribeRequest
- func NewVerifyRequest(peerID, orgID ecid.ID, key id.ID, macKey []byte, nPeers uint) *api.VerifyRequest
- type Balancer
- type Claims
- type FinderCreator
- type GetterBalancer
- type IntroducerCreator
- type Pool
- type PutterBalancer
- type SetBalancer
- type Signer
- type StorerCreator
- type TestErrSigner
- type TestNoOpSigner
- type Verifier
- type VerifierCreator
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyLibrarianAddresses indicates that the librarian addresses is empty. ErrEmptyLibrarianAddresses = errors.New("empty librarian addresses") // ErrClientMissingFromSet indicates when a client ID is expected to be in a set but isn't. ErrClientMissingFromSet = errors.New("client missing from set") // ErrNoNewClients indicates when Next() cannot return a new LibrarianClient because no // new clients were available. ErrNoNewClients = errors.New("no new LibrarianClients are available") )
var ( // ErrGetMissingValue denotes when a Get request expects to receive a value response but // doesn't and instead receives a ClosestPeers response. ErrGetMissingValue = errors.New("Get response expected to have value but it is missing") )
var ErrUnexpectedRequestID = errors.New("response contains unexpected RequestID")
ErrUnexpectedRequestID indicates when the RequestID in a response is different than that in the request.
Functions ¶
func FromSignatureContext ¶
FromSignatureContext extracts the signed JSON web token from the context.
func NewExpBackoff ¶
func NewExpBackoff(timeout time.Duration) *cbackoff.ExponentialBackOff
NewExpBackoff creates a new exponential backoff retrier with default parameters.
func NewFindRequest ¶
NewFindRequest creates a FindRequest object.
func NewGetRequest ¶
NewGetRequest creates a GetRequest object.
func NewIncomingSignatureContext ¶
func NewIncomingSignatureContext( ctx context.Context, signedJWT, orgSignedJWT string, ) context.Context
NewIncomingSignatureContext creates a new context with the signed JSON web token (JWT) string in the incoming metadata field. This function should only be used for testing.
func NewIntroduceRequest ¶
func NewIntroduceRequest( peerID, orgID ecid.ID, apiSelf *api.PeerAddress, nPeers uint, ) *api.IntroduceRequest
NewIntroduceRequest creates an IntroduceRequest object.
func NewPutRequest ¶
NewPutRequest creates a PutRequest object.
func NewRequestMetadata ¶
func NewRequestMetadata(peerID, orgID ecid.ID) *api.RequestMetadata
NewRequestMetadata creates a RequestMetadata object from the peer ID and a random request ID.
func NewRetryFinder ¶
NewRetryFinder creates a new api.Finder with exponential backoff retries.
func NewRetryGetter ¶
NewRetryGetter wraps a client balancer with an exponential backoff, returning an api.Getter. Each backoff attempt samples a (possibly) different api.Getter to use for the query.
func NewRetryPutter ¶
func NewRetryPutter(cb PutterBalancer, timeout time.Duration) api.Putter
NewRetryPutter wraps a client balancer with an exponential backoff, returning an api.Putter.
func NewRetryStorer ¶
NewRetryStorer creates a new api.Storer with exponential backoff retries.
func NewRetryVerifier ¶
NewRetryVerifier creates a new api.Finder with exponential backoff retries.
func NewSignatureContext ¶
NewSignatureContext creates a new context with the signed JSON web token (JWT) string.
func NewSignedContext ¶
NewSignedContext creates a new context with a request signature.
func NewSignedTimeoutContext ¶
func NewSignedTimeoutContext( signer, orgSigner Signer, request proto.Message, timeout time.Duration, ) ( context.Context, context.CancelFunc, error)
NewSignedTimeoutContext creates a new context with a timeout and request signature.
func NewStoreRequest ¶
NewStoreRequest creates a StoreRequest object.
func NewSubscribeRequest ¶
func NewSubscribeRequest( peerID, orgID ecid.ID, subscription *api.Subscription, ) *api.SubscribeRequest
NewSubscribeRequest creates a SubscribeRequest object.
func NewVerifyRequest ¶
func NewVerifyRequest( peerID, orgID ecid.ID, key id.ID, macKey []byte, nPeers uint, ) *api.VerifyRequest
NewVerifyRequest creates a VerifyRequest object.
Types ¶
type Balancer ¶
type Balancer interface { // Next selects the next LibrarianClient. Next() (api.LibrarianClient, error) // CloseAll closes all LibrarianClient connections. CloseAll() error }
Balancer load balances between a collection of LibrarianClients.
type Claims ¶
type Claims struct { // Hash is the base-64-url encoded string of the hash of the message being signed Hash string `json:"hash"` }
Claims holds the claims associated with a message signature.
func NewSignatureClaims ¶
NewSignatureClaims creates a new SignatureClaims instance with the given message hash.
type FinderCreator ¶
type FinderCreator interface { // Create creates an api.Finder from the api.Connector. Create(address string) (api.Finder, error) }
FinderCreator creates api.Finders.
func NewFinderCreator ¶
func NewFinderCreator(clients Pool) FinderCreator
NewFinderCreator creates a new FinderCreator.
type GetterBalancer ¶
GetterBalancer load balances between a collection of Getters.
func NewUniformGetterBalancer ¶
func NewUniformGetterBalancer(inner Balancer) GetterBalancer
NewUniformGetterBalancer creates a GetterBalancer using an internal Balancer.
type IntroducerCreator ¶
type IntroducerCreator interface { // Create creates an api.Introducer from the api.Connector. Create(address string) (api.Introducer, error) }
IntroducerCreator creates api.Introducers.
func NewIntroducerCreator ¶
func NewIntroducerCreator(clients Pool) IntroducerCreator
NewIntroducerCreator creates a new IntroducerCreator.
type Pool ¶ added in v0.3.0
type Pool interface { // Get the connection to the given address. Get(address string) (api.LibrarianClient, error) // CloseAll closes all active connections. Not further Get() calls may be made after this call. CloseAll() error }
Pool maintains a pool of librarian clients.
func NewDefaultLRUPool ¶ added in v0.3.0
NewDefaultLRUPool creates a new LRU pool with the default number of max connections.
func NewLRUPool ¶ added in v0.3.0
NewLRUPool creates a new LRU Pool with the given number of max connections.
type PutterBalancer ¶
PutterBalancer laod balances between a collection of Putters.
func NewUniformPutterBalancer ¶
func NewUniformPutterBalancer(inner Balancer) PutterBalancer
NewUniformPutterBalancer creates a PutterBalancer using an internal Balancer.
type SetBalancer ¶
type SetBalancer interface { // AddNext selects the next LibrarianClient, adds it to the set, and returns it along with // its peer address string. AddNext() (api.LibrarianClient, string, error) // Remove removes the librarian from the set. Remove(address string) error }
SetBalancer load balances between librarian clients, ensuring that a new librarian is always returned.
func NewSetBalancer ¶ added in v0.4.0
NewSetBalancer creates a new SetBalancer that selects the next client from the remaining clients in the available set.
type Signer ¶
type Signer interface { // Sign returns the signature (in the form of an encoded json web token) on the message. Sign(m proto.Message) (string, error) }
Signer can sign a message.
func NewECDSASigner ¶ added in v0.5.0
func NewECDSASigner(key *ecdsa.PrivateKey) Signer
NewECDSASigner returns a new Signer instance using the given private key.
func NewEmptySigner ¶ added in v0.5.0
func NewEmptySigner() Signer
NewEmptySigner returns a Signer than returns an empty string signature instead of actually signing the message.
type StorerCreator ¶
type StorerCreator interface { // Create creates an api.Storer from the api.Connector. Create(address string) (api.Storer, error) }
StorerCreator creates api.Storers.
func NewStorerCreator ¶
func NewStorerCreator(clients Pool) StorerCreator
NewStorerCreator creates a new StorerCreator.
type TestErrSigner ¶
type TestErrSigner struct{}
TestErrSigner implements the signature.Signer interface but always returns an error.
type TestNoOpSigner ¶
type TestNoOpSigner struct{}
TestNoOpSigner implements the signature.Signer interface but just returns a dummy token.
type Verifier ¶
type Verifier interface { // Verify verifies that the encoded token is well formed and has been signed by the peer. Verify(encToken string, fromPubKey *ecdsa.PublicKey, m proto.Message) error }
Verifier verifies the signature on a message.
type VerifierCreator ¶
type VerifierCreator interface { // Create creates an api.Verifier from the api.Connector. Create(address string) (api.Verifier, error) }
VerifierCreator creates api.Verifiers.
func NewVerifierCreator ¶
func NewVerifierCreator(clients Pool) VerifierCreator
NewVerifierCreator creates a new FinderCreator.