-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.go
37 lines (32 loc) · 1.15 KB
/
backend.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright (C) 2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package backend
import (
"context"
"time"
)
// Node provides an interface to interact with a node on a given network
type Node interface {
GetName() string
Config() map[string]interface{}
GetHTTPBaseURI() string
GetBootstrapIP() string
Stop(timeout time.Duration) error // TODO pass in [ctx] instead of [timeout]
}
// Network provides an interface for configuring Nodes
type Network interface {
// GetNodes returns the names of each node in the network
GetNodes() []Node
// GetNode returns the Node corresponding to [name]
GetNode(name string) (Node, bool)
// AddNode adds new node to the network
AddNode(ctx context.Context, config NodeConfig) (Node, error)
// Teardown stops the network and additionally tears down all of the resources associated with it
Teardown(ctx context.Context) error
}
// NetworkOrchestrator provides an interface to orchestrate networks using an arbitrary backend
type NetworkOrchestrator interface {
CreateNetwork(name string) (Network, error)
GetNetwork(name string) (Network, bool)
Teardown(ctx context.Context) error
}