Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- type Executor
- type FStore
- type HandlerFunc
- type Node
- func (n *Node) ExecuteFunction(ctx context.Context, req execute.Request) (codes.Code, string, execute.ResultMap, execute.Cluster, error)
- func (n *Node) ExecutionResult(id string) (execute.Result, bool)
- func (n *Node) HealthPing(ctx context.Context)
- func (n *Node) ID() string
- func (n *Node) PublishFunctionInstall(ctx context.Context, uri string, cid string) error
- func (n *Node) Run(ctx context.Context) error
- func (n *Node) ValidateConfig() error
- type Option
- func WithClusterFormationTimeout(d time.Duration) Option
- func WithConcurrency(n uint) Option
- func WithConsensusElectionTimeout(d time.Duration) Option
- func WithConsensusHeartbeatTimeout(d time.Duration) Option
- func WithConsensusLeaderLease(d time.Duration) Option
- func WithExecutionTimeout(d time.Duration) Option
- func WithExecutor(execute Executor) Option
- func WithHealthInterval(d time.Duration) Option
- func WithRole(role blockless.NodeRole) Option
- func WithRollCallTimeout(d time.Duration) Option
- func WithTopic(topic string) Option
- func WithWorkspace(path string) Option
- type PeerStore
- type Store
Constants ¶
const ( DefaultTopic = "blockless/b7s/general" DefaultHealthInterval = 1 * time.Minute DefaultRollCallTimeout = 5 * time.Second DefaultExecutionTimeout = 10 * time.Second DefaultClusterFormationTimeout = 10 * time.Second DefaultConcurrency = 10 )
const ( DefaultRaftHeartbeatTimeout = 300 * time.Millisecond DefaultRaftElectionTimeout = 300 * time.Millisecond DefaultRaftLeaderLease = 200 * time.Millisecond )
Raft and consensus related parameters.
Variables ¶
var DefaultConfig = Config{ Role: blockless.WorkerNode, Topic: DefaultTopic, HealthInterval: DefaultHealthInterval, RollCallTimeout: DefaultRollCallTimeout, Concurrency: DefaultConcurrency, ExecutionTimeout: DefaultExecutionTimeout, ClusterFormationTimeout: DefaultClusterFormationTimeout, ConsensusHeartbeatTimeout: DefaultRaftHeartbeatTimeout, ConsensusElectionTimeout: DefaultRaftElectionTimeout, ConsensusLeaderLease: DefaultRaftLeaderLease, }
DefaultConfig represents the default settings for the node.
var (
ErrUnsupportedMessage = errors.New("unsupported message")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Role blockless.NodeRole // Node role.
Topic string // Topic to subscribe to.
Execute Executor // Executor to use for running functions.
HealthInterval time.Duration // How often should we emit the health ping.
RollCallTimeout time.Duration // How long do we wait for roll call responses.
Concurrency uint // How many requests should the node process in parallel.
ExecutionTimeout time.Duration // How long does the head node wait for worker nodes to send their execution results.
ClusterFormationTimeout time.Duration // How long do we wait for the nodes to form a cluster for an execution.
Workspace string // Directory where we can store files needed for execution.
ConsensusHeartbeatTimeout time.Duration // How often a consensus cluster leader should ping its followers.
ConsensusElectionTimeout time.Duration // How long does a consensus cluster node wait for a leader before it triggers an election.
ConsensusLeaderLease time.Duration // How long does a leader remain a leader if it cannot contact a quorum of cluster nodes.
}
Config represents the Node configuration.
type FStore ¶
type FStore interface {
// Install will install a function based on the address and CID.
Install(address string, cid string) error
// Installed returns info if the function is installed or not.
Installed(cid string) (bool, error)
// InstalledFunction returns the list of CIDs of installed functions.
InstalledFunctions() ([]string, error)
// Sync will recheck if function installation is found in local storage, and redownload it if it isn't.
Sync(cid string) error
}
FStore provides retrieval of function manifest.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is the entity that actually provides the main Blockless node functionality. It listens for messages coming from the wire and processes them. Depending on the node role, which is determined on construction, it may process messages in different ways. For example, upon receiving a message requesting execution of a Blockless function, a Worker Node will use the `Execute` component to fullfill the execution request. On the other hand, a Head Node will issue a roll call and eventually delegate the execution to the chosend Worker Node.
func New ¶
func New(log zerolog.Logger, host *host.Host, peerStore PeerStore, fstore FStore, options ...Option) (*Node, error)
New creates a new Node.
func (*Node) ExecuteFunction ¶
func (n *Node) ExecuteFunction(ctx context.Context, req execute.Request) (codes.Code, string, execute.ResultMap, execute.Cluster, error)
ExecuteFunction can be used to start function execution. At the moment this is used by the API server to start execution on the head node.
func (*Node) ExecutionResult ¶
ExecutionResult fetches the execution result from the node cache.
func (*Node) HealthPing ¶
HealthPing will run a long running loop, publishing health signal until cancelled.
func (*Node) PublishFunctionInstall ¶
PublishFunctionInstall publishes a function install message.
func (*Node) ValidateConfig ¶
Validate checks if the given configuration is correct.
type Option ¶
type Option func(*Config)
Option can be used to set Node configuration options.
func WithClusterFormationTimeout ¶
WithClusterFormationTimeout specifies how long does the head node wait for worker nodes to form a consensus cluster.
func WithConcurrency ¶
WithConcurrency specifies how many requests the node should process in parallel.
func WithConsensusElectionTimeout ¶
WithConsensusElectionTimeout sets the election timeout for the consensus cluster.
func WithConsensusHeartbeatTimeout ¶
WithConsensusHeartbeatTimeout sets the heartbeat timeout for the consensus cluster.
func WithConsensusLeaderLease ¶
WithConsensusLeaderLease sets the leader lease for the consensus cluster leader.
func WithExecutionTimeout ¶
WithExecutionTimeout specifies how long does the head node wait for worker nodes to send their execution results.
func WithExecutor ¶
WithExecutor specifies the executor to be used for running Blockless functions
func WithHealthInterval ¶
WithHealthInterval specifies how often we should emit the health signal.
func WithRollCallTimeout ¶
WithRollCallTimeout specifies how long do we wait for roll call responses.
func WithWorkspace ¶
WithWorkspace specifies the workspace that the node can use for file storage.