A very experimental PLC implementation which uses BFT consensus for decentralization
at main 55 lines 1.8 kB view raw
1package config 2 3import ( 4 "time" 5 6 bftconfig "github.com/cometbft/cometbft/config" 7) 8 9type UnifiedConfig struct { 10 *bftconfig.Config `mapstructure:",squash"` 11 12 PLC *PLCConfig `mapstructure:"plc"` 13} 14 15func DefaultConfig() *UnifiedConfig { 16 return &UnifiedConfig{ 17 Config: bftconfig.DefaultConfig(), 18 PLC: DefaultPLCConfig(), 19 } 20} 21 22type PLCConfig struct { 23 // Address to listen for incoming connections 24 ListenAddress string `mapstructure:"laddr"` 25 26 // Whether to expose pprof endpoints for debugging 27 Pprof bool `mapstructure:"pprof"` 28 29 // Maximum age of a cursor for the streaming export endpoint. 30 // If set to 0, the OutdatedCursor error is disabled entirely. 31 MaxStreamingExportCursorAge time.Duration `mapstructure:"max_streaming_export_cursor_age"` 32 33 // Server response timeout for API endpoints 34 ResponseTimeout time.Duration `mapstructure:"response_timeout"` 35 36 // SnapshotInterval defines the number of blocks between automatic snapshots. 37 // If set to 0, automatic snapshot creation is disabled. 38 SnapshotInterval uint64 `mapstructure:"snapshot_interval"` 39 40 // SnapshotRetentionCount defines the maximum number of snapshots to retain. 41 // When creating a new snapshot, older snapshots are automatically deleted. 42 // If set to 0, all snapshots are retained. 43 SnapshotRetentionCount uint64 `mapstructure:"snapshot_retention_count"` 44} 45 46func DefaultPLCConfig() *PLCConfig { 47 return &PLCConfig{ 48 ListenAddress: "tcp://127.0.0.1:28080", 49 Pprof: true, // TODO set to false once we move past alpha phase 50 MaxStreamingExportCursorAge: 7 * 24 * time.Hour, 51 ResponseTimeout: 10 * time.Second, 52 SnapshotInterval: 0, // Disable snapshots by default 53 SnapshotRetentionCount: 1, 54 } 55}