core

package
v0.0.0-...-0001d10 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubID

func SubID(key string, id uint64) string

SubID generates a subscription ID that uniquely identifies a subscription within the global namespace

func SubinfoID

func SubinfoID(key string) string

SubinfoID generates the ID that uniquely identifies the managed subscriptions of a session

Types

type Client

Client is an interface for any type that sends requests and receives responses

type CreateSubscriptionRequest

type CreateSubscriptionRequest struct {
	// Event is the subscription event type
	Event string

	// Address will be used to filter events only issues by or to
	// the address
	Address string

	// SubID is the unique subscription's identifier
	SubID string

	// Topics is the list of topics the client is interested in
	Topics []string
}

CreateSubscriptionRequest is the request to subscribe to a specific event type for a service

type DataEvent

type DataEvent struct {
	// ID to identify the event itself within the sequence of events.
	ID uint64

	// Data is the blob of data related to this event
	Data string

	// Topics is the list of topics to which this event refers
	Topics []string
}

DataEvent is that event that can be polled by the user to poll for service logs for example, which they are a blob of data that the client knows how to manipulate

func (DataEvent) EventID

func (e DataEvent) EventID() uint64

EventID is the implementation of rpc.Event for DataEvent

func (DataEvent) EventType

func (e DataEvent) EventType() EventType

EventType is the implementation of Event for ErrorResponse

type DeployServiceRequest

type DeployServiceRequest struct {
	// AAD is the identifier of the issuer of the transaction data
	AAD string

	// Data is a blob of data that the user wants to pass as argument for
	// the deployment of a service
	Data string

	// Key is the identifier of the session
	SessionKey string
}

DeployServiceRequest is issued by the user to trigger a service execution. A client is always subscribed to a subscription with topic "service" from which the client can retrieve the asynchronous results to this request

type DeployServiceResponse

type DeployServiceResponse struct {
	// ID to identify an asynchronous response. It uniquely identifies the
	// event and orders it in the sequence of events expected by the user
	ID uint64

	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string
}

DeployServiceResponse is the event that can be polled by the user as a result to a ServiceDeployRequest

func (DeployServiceResponse) EventID

func (e DeployServiceResponse) EventID() uint64

EventID is the implementation of rpc.Event for DeployServiceResponse

func (DeployServiceResponse) EventType

func (e DeployServiceResponse) EventType() EventType

EventType is the implementation of Event for DeployServiceResponse

type DestroySubscriptionRequest

type DestroySubscriptionRequest struct {
	// SubID is the unique subscription's identifier
	SubID string
}

UnsubscribeRequest is a request issued by the client to destroy an existing subscription

type ErrorEvent

type ErrorEvent struct {
	// ID to identify an asynchronous response. It uniquely identifies the
	// event and orders it in the sequence of events expected by the user
	ID uint64

	// Cause is the error that caused the event to failed
	Cause rpc.Error
}

ErrorEvent is the event that can be polled by the user as a result to a a request that failed

func (ErrorEvent) EventID

func (e ErrorEvent) EventID() uint64

EventID is the implementation of rpc.Event for ErrorEvent

func (ErrorEvent) EventType

func (e ErrorEvent) EventType() EventType

EventType is the implementation of Event for ErrorResponse

type Event

type Event interface {
	EventID() uint64
	EventType() EventType
}

type EventType

type EventType string
const (
	DeployServiceEventType  EventType = "deployServiceEventType"
	ExecuteServiceEventType EventType = "executeServiceEventType"
	ErrorEventType          EventType = "errorEventType"
	DataEventType           EventType = "dataEventType"
)

func (EventType) String

func (t EventType) String() string

type Events

type Events struct {
	Offset uint64
	Events []Event
}

type ExecuteServiceRequest

type ExecuteServiceRequest struct {
	// AAD is the identifier of the issuer of the transaction data
	AAD string

	// Data is a blob of data that the user wants to pass to the service
	// as argument
	Data string

	// Address where the service can be found
	Address string

	// Key is the identifier of the session
	SessionKey string
}

ExecuteServiceRequest is is used by the user to trigger a service execution. A client is always subscribed to a subscription with topic "service" from which the client can retrieve the asynchronous results to this request

type ExecuteServiceResponse

type ExecuteServiceResponse struct {
	// ID to identify an asynchronous response. It uniquely identifies the
	// event and orders it in the sequence of events expected by the user
	ID uint64

	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string

	// Output generated by the service at the end of its execution
	Output string
}

ExecuteServiceResponse is the event that can be polled by the user as a result to a ServiceExecutionRequest

func (ExecuteServiceResponse) EventID

func (e ExecuteServiceResponse) EventID() uint64

EventID is the implementation of Event for ExecuteServiceResponse

func (ExecuteServiceResponse) EventType

func (e ExecuteServiceResponse) EventType() EventType

EventType is the implementation of Event for ExecuteServiceResponse

type GetCodeRequest

type GetCodeRequest struct {
	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string `json:"address"`
}

GetCodeRequest is a request to retrieve the code associated with a specific service

type GetCodeResponse

type GetCodeResponse struct {
	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string

	// Code associated with the service
	Code string
}

GetCodeResponse is the response in which the code associated with the service is provided

type GetExpiryRequest

type GetExpiryRequest struct {
	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string `json:"address"`
}

GetExpiryRequest is a request to retrieve the expiration timestamp associated with a specific service

type GetExpiryResponse

type GetExpiryResponse struct {
	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string

	// Expiry associated with the service
	Expiry uint64
}

GetExpiryResponse is the response in which the public key associated with the service is provided

type GetPublicKeyRequest

type GetPublicKeyRequest struct {
	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string `json:"address"`
}

GetPublicKeyRequest is a request to retrieve the public key associated with a specific service

type GetPublicKeyResponse

type GetPublicKeyResponse struct {
	// Timestamp at which the key expired
	Timestamp uint64

	// Address is the unique address that identifies the service,
	// is generated when a service is deployed and it can be used
	// for service execution
	Address string

	// PublicKey associated with the service
	PublicKey string

	// Signature from the key manager to authenticate the public key
	Signature string
}

GetPublicKeyResponse is the response in which the public key associated with the service is provided

type PollEventRequest

type PollEventRequest struct {
	// Offset at which events need to be provided. Events are all ordered
	// with sequence numbers and it is up to the client to specify which
	// events it wants to receive from an offset in the sequence
	Offset uint64

	// Count for the number of items the client would prefer to receive
	// at most from a single response
	Count uint

	// DiscardPrevious allows the client to define whether the server should
	// discard all the events that have a sequence number lower than the offer
	DiscardPrevious bool

	// ID is the unique identifier for a subscription based on
	// the user's key namespace
	ID uint64

	// Key is the identifier of the session
	SessionKey string
}

PollEventRequest is a request issued by the client to poll events from an already created subscription

type PollServiceRequest

type PollServiceRequest struct {
	// Offset at which events need to be provided. Events are all ordered
	// with sequence numbers and it is up to the client to specify which
	// events it wants to receive from an offset in the sequence
	Offset uint64

	// Count for the number of items the client would prefer to receive
	// at most from a single response
	Count uint

	// DiscardPrevious allows the client to define whether the server should
	// discard all the events that have a sequence number lower than the offer
	DiscardPrevious bool

	// Key is the identifier of the request issuer
	SessionKey string
}

PollServiceRequest is a request issued by a client to retrieve a window of responses generated by asynchronous requests

type RequestManager

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

RequestManager handles the client RPC requests. Most requests are asynchronous and they are handled by returning an identifier that the caller can later on query to find out the outcome of the request.

func NewRequestManager

func NewRequestManager(properties RequestManagerProperties) *RequestManager

NewRequestManager creates a new instance of a request manager

func (*RequestManager) DeployServiceAsync

func (m *RequestManager) DeployServiceAsync(ctx context.Context, req DeployServiceRequest) (uint64, errors.Err)

RequestManager starts a request and provides an identifier for the caller to find the request later on. Deploys a new service

func (*RequestManager) ExecuteServiceAsync

func (m *RequestManager) ExecuteServiceAsync(
	ctx context.Context,
	req ExecuteServiceRequest,
) (uint64, errors.Err)

RequestManager starts a request and provides an identifier for the caller to find the request later on. Executes an operation on a service

func (*RequestManager) GetCode

GetCode retrieves the source code for a specific service

func (*RequestManager) GetExpiry

GetExpiry retrieves the expiration timestamp for a specific service

func (*RequestManager) GetPublicKey

GetPublicKey retrieves the public key for a specific service

func (*RequestManager) Name

func (m *RequestManager) Name() string

func (*RequestManager) PollEvent

func (m *RequestManager) PollEvent(ctx context.Context, req PollEventRequest) (Events, errors.Err)

PollEvent retrieves the responses the RequestManager already got from the asynchronous requests.

func (*RequestManager) PollService

func (m *RequestManager) PollService(ctx context.Context, req PollServiceRequest) (Events, errors.Err)

PollService retrieves the responses the RequestManager already got from the asynchronous requests.

func (*RequestManager) Senders

func (m *RequestManager) Senders() []ethereum.Address

func (*RequestManager) Stats

func (m *RequestManager) Stats() stats.Metrics

func (*RequestManager) Subscribe

func (m *RequestManager) Subscribe(ctx context.Context, req SubscribeRequest) (uint64, errors.Err)

Subscribe creates a new subscription using the underlying backend and allocates the necessary resources from the store

func (*RequestManager) Unsubscribe

func (m *RequestManager) Unsubscribe(ctx context.Context, req UnsubscribeRequest) errors.Err

Unsubscribe from an existing subscription freeing all the associated resources. After this operation all events from the subscription stream will be lost.

type RequestManagerProperties

type RequestManagerProperties struct {
	MQueue mqueue.MQueue
	Client Client
	Logger log.Logger
}

type SubscribeRequest

type SubscribeRequest struct {
	// Event is the subscription event to subscribe to
	Event string

	// Address will be used to filter events only issues by or to
	// the address
	Address string

	// Key is the identifier of the session
	SessionKey string

	// Topics is the list of topics the subscription client is
	// interested in
	Topics []string
}

SubscribeRequest is a request issued by the client to subscribe to a specific event type and receive events from it until the subscription is closed

type SubscriptionManager

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

SubscriptionManager manages the lifetime of a group of subscriptions

func NewSubscriptionManager

func NewSubscriptionManager(props SubscriptionManagerProps) *SubscriptionManager

NewSubscriptionManager creates a new subscription manager

func (*SubscriptionManager) Create

func (m *SubscriptionManager) Create(
	ctx context.Context,
	key string,
	c chan interface{},
) errors.Err

Create a new subscription identified by the specified key

func (*SubscriptionManager) Destroy

func (m *SubscriptionManager) Destroy(
	ctx context.Context,
	key string,
) errors.Err

Destroy an existing subscription identified by the specified key

func (*SubscriptionManager) Exists

func (m *SubscriptionManager) Exists(
	ctx context.Context,
	key string,
) bool

Exists returns true if the subscription exists

func (*SubscriptionManager) Stats

func (m *SubscriptionManager) Stats() stats.Metrics

type SubscriptionManagerProps

type SubscriptionManagerProps struct {
	// Context used by the manager and that can be used
	// to signal a cancellation
	Context context.Context

	// Logger used by the manager and its subscriptions
	Logger log.Logger

	// Mqueue is the messaging queue used to keep the
	// stream of events so that the client can retrieve
	// those events later on
	MQueue mqueue.MQueue
}

SubscriptionManagerProps properties used to create the behaviour of the manager and the subscriptions created

type SubscriptionMetrics

type SubscriptionMetrics struct {
	SubscriptionCount      uint64
	SubscriptionCurrent    uint64
	TotalSubscriptionCount uint64
}

type UnsubscribeRequest

type UnsubscribeRequest struct {
	// ID is the unique identifier for a subscription based on
	// the user's key namespace
	ID uint64

	// Key is the identifier of the session
	SessionKey string
}

UnsubscribeRequest is a request issued by the client to subscribe to a specific topic and receive events from it until the subscription is closed

Jump to

Keyboard shortcuts

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