-
Notifications
You must be signed in to change notification settings - Fork 175
/
config.go
72 lines (62 loc) · 2.76 KB
/
config.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package backend
import (
"errors"
"time"
"github.com/onflow/flow-go/engine/access/rpc/connection"
)
// Config defines the configurable options for creating Backend
type Config struct {
ExecutionClientTimeout time.Duration // execution API GRPC client timeout
CollectionClientTimeout time.Duration // collection API GRPC client timeout
ConnectionPoolSize uint // size of the cache for storing collection and execution connections
MaxHeightRange uint // max size of height range requests
PreferredExecutionNodeIDs []string // preferred list of upstream execution node IDs
FixedExecutionNodeIDs []string // fixed list of execution node IDs to choose from if no node ID can be chosen from the PreferredExecutionNodeIDs
CircuitBreakerConfig connection.CircuitBreakerConfig // the configuration for circuit breaker
ScriptExecutionMode string // the mode in which scripts are executed
EventQueryMode string // the mode in which events are queried
TxResultQueryMode string // the mode in which tx results are queried
}
type IndexQueryMode int
const (
// IndexQueryModeLocalOnly executes scripts and gets accounts using only local storage
IndexQueryModeLocalOnly IndexQueryMode = iota + 1
// IndexQueryModeExecutionNodesOnly executes scripts and gets accounts using only
// execution nodes
IndexQueryModeExecutionNodesOnly
// IndexQueryModeFailover executes scripts and gets accounts using local storage first,
// then falls back to execution nodes if data is not available for the height or if request
// failed due to a non-user error.
IndexQueryModeFailover
// IndexQueryModeCompare executes scripts and gets accounts using both local storage and
// execution nodes and compares the results. The execution node result is always returned.
IndexQueryModeCompare
)
func ParseIndexQueryMode(s string) (IndexQueryMode, error) {
switch s {
case IndexQueryModeLocalOnly.String():
return IndexQueryModeLocalOnly, nil
case IndexQueryModeExecutionNodesOnly.String():
return IndexQueryModeExecutionNodesOnly, nil
case IndexQueryModeFailover.String():
return IndexQueryModeFailover, nil
case IndexQueryModeCompare.String():
return IndexQueryModeCompare, nil
default:
return 0, errors.New("invalid script execution mode")
}
}
func (m IndexQueryMode) String() string {
switch m {
case IndexQueryModeLocalOnly:
return "local-only"
case IndexQueryModeExecutionNodesOnly:
return "execution-nodes-only"
case IndexQueryModeFailover:
return "failover"
case IndexQueryModeCompare:
return "compare"
default:
return ""
}
}