Repository navigation
Expand file tree
/
Copy pathconfig.go
More file actions
59 lines (50 loc) · 2.02 KB
/
Copy pathconfig.go
File metadata and controls
59 lines (50 loc) · 2.02 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
package chronicle
import (
"time"
"github.com/xraph/chronicle/hash"
)
// Config holds the configuration for a Chronicle instance.
type Config struct {
// BatchSize is the maximum number of events to accumulate before flushing.
//
// Not applied by [Chronicle.Record], which writes each event synchronously:
// linking an event into the hash chain needs the previous event's hash, so
// appends are inherently sequential. The batcher package implements batching
// for callers that drive it directly.
BatchSize int
// FlushInterval is the maximum time to wait before flushing accumulated events.
//
// Not applied by [Chronicle.Record]. See BatchSize.
FlushInterval time.Duration
// ShutdownTimeout is the maximum time to wait for graceful shutdown.
ShutdownTimeout time.Duration
// EnableCryptoErasure encrypts each subject's personal payload under a
// per-subject key, so destroying the key makes it irrecoverable.
//
// Requires a sealer from [WithSealer]; see [ErrCryptoErasureUnavailable].
EnableCryptoErasure bool
// RetentionCheckInterval is how often the retention enforcer runs.
RetentionCheckInterval time.Duration
// DigestScheme selects how each event's digest is computed. The default,
// hash.SchemePlainV4, is unkeyed and reproducible by anyone who can read
// the store, so it detects corruption rather than tampering.
//
// hash.SchemeHMACV5 requires a key provider; see [ErrHMACKeyUnavailable].
//
// hash.SchemePlain and hash.SchemeHMAC are verify-only. Setting either one
// fails at New rather than at the first event, because their content
// encoding is ambiguous and a digest written under them can be forged
// without the key.
DigestScheme hash.Scheme
}
// DefaultConfig returns a Config with sensible defaults.
func DefaultConfig() Config {
return Config{
BatchSize: 100,
FlushInterval: time.Second,
ShutdownTimeout: 30 * time.Second,
EnableCryptoErasure: false,
RetentionCheckInterval: 24 * time.Hour,
DigestScheme: hash.SchemePlainV4,
}
}