-
Notifications
You must be signed in to change notification settings - Fork 76
Expand file tree
/
Copy pathconfig.go
More file actions
68 lines (58 loc) · 1.81 KB
/
Copy pathconfig.go
File metadata and controls
68 lines (58 loc) · 1.81 KB
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
// Copyright 2025 Democratized Data Foundation
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.
package db
import (
"time"
"github.com/sourcenetwork/immutable"
"github.com/sourcenetwork/lens/host-go/engine/module"
"github.com/sourcenetwork/defradb/client/options"
intOpts "github.com/sourcenetwork/defradb/internal/options"
)
const (
defaultMaxTxnRetries = 5
updateEventBufferSize = 100
)
func defaultDBConfig() intOpts.DBOptions {
return intOpts.DBOptions{
NodeDBOptions: options.NodeDBOptions{
MaxTxnRetries: immutable.Some(defaultMaxTxnRetries),
EnableSigning: true,
RetryIntervals: []time.Duration{
time.Second * 30,
time.Minute,
time.Minute * 2,
time.Minute * 4,
time.Minute * 8,
time.Minute * 16,
time.Minute * 32,
},
P2PBlockSyncTimeout: time.Second * 30,
},
}
}
type LensRuntimeType string
const (
// The Go-enum default LensRuntimeType.
//
// The actual runtime type that this resolves to depends on the build target.
DefaultLens LensRuntimeType = ""
)
// runtimeConstructors is a map of [LensRuntimeType]s to lens runtimes.
//
// Is is populated by the `init` functions in the runtime-specific files - this
// allows it's population to be managed by build flags.
var runtimeConstructors = map[LensRuntimeType]func() module.Runtime{}
func newLensRuntime(runtimeType LensRuntimeType) (module.Runtime, error) {
if runtimeConstructor, ok := runtimeConstructors[runtimeType]; ok {
return runtimeConstructor(), nil
} else {
return nil, NewErrLensRuntimeNotSupported(runtimeType)
}
}