api

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: 3 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ContextProvider

type ContextProvider interface {
	InitiateContext(view view.View) (view.Context, error)
	InitiateContextWithIdentity(view view.View, id view.Identity) (view.Context, error)
	Context(contextID string) (view.Context, error)
}

type FabricSmartClientNode

type FabricSmartClientNode interface {
	ServiceProvider
	ViewRegistry
	ContextProvider
	ViewClient

	Start() error

	Stop()
}

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 SDK

type SDK interface {
	Install() error

	Start(ctx context.Context) error
}

type ServiceOption

type ServiceOption func(*ServiceOptions) error

func WithChannel

func WithChannel(channel string) ServiceOption

func WithNetwork

func WithNetwork(network string) ServiceOption

func WithTimeout

func WithTimeout(timeout time.Duration) ServiceOption

type ServiceOptions

type ServiceOptions struct {
	Network string
	Channel string
	Timeout time.Duration
}

func CompileServiceOptions

func CompileServiceOptions(opts ...ServiceOption) (*ServiceOptions, error)

type ServiceProvider

type ServiceProvider interface {
	GetService(v interface{}) (interface{}, error)

	RegisterService(service interface{}) error
}

type ViewClient

type ViewClient interface {
	// CallView takes in input a view factory identifier, fid, and an input, in, and invokes the
	// factory f bound to fid on input in. The view returned by the factory is invoked on
	// a freshly created context. This call is blocking until the result is produced or
	// an error is returned.
	CallView(fid string, in []byte) (interface{}, error)

	// Initiate takes in input a view factory identifier, fid, and an input, in, and invokes the
	// factory f bound to fid on input in. The view returned by the factory is invoked on
	// a freshly created context whose identifier, cid, is immediately returned.
	// This call is non-blocking.
	Initiate(fid string, in []byte) (string, error)

	// Track takes in input a context identifier, cid, and returns the latest
	// status of the context as set by the views using it.
	Track(cid string) string

	// IsTxFinal takes in input a transaction id and return nil if the transaction has been committed,
	// an error otherwise.
	IsTxFinal(txid string, opts ...ServiceOption) error
}

type ViewRegistry

type ViewRegistry interface {
	// RegisterFactory binds an id to a View Factory
	RegisterFactory(id string, factory Factory) 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.
	RegisterResponder(responder view.View, 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.
	RegisterResponderWithIdentity(responder view.View, id view.Identity, initiatedBy view.View) error
}

ViewRegistry keeps track of the available views and view factories

Jump to

Keyboard shortcuts

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