-
Notifications
You must be signed in to change notification settings - Fork 0
/
repo_loader_configurator.go
71 lines (60 loc) · 2.56 KB
/
repo_loader_configurator.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
package sourcing
import "time"
// RepoLoaderConfigurator is responsible for setting up load options for the repository.
type RepoLoaderConfigurator struct {
loadOptions RepoLoadOptions
}
// RepoLoadOptions holds the configuration options for loading from the repository.
type RepoLoadOptions struct {
lev *LoadEventsOptions
skipSnapshot bool
}
// NewRepoLoaderConfigurator creates a new instance of RepoLoaderConfigurator with default settings.
func NewRepoLoaderConfigurator() *RepoLoaderConfigurator {
return &RepoLoaderConfigurator{
loadOptions: RepoLoadOptions{
lev: &LoadEventsOptions{},
},
}
}
// MinVersion sets the minimum version of the aggregate to load and returns the configurator.
// NOTE: this will lead to inconsistent state if you're loading against an aggregate. Only use
// this if you're directly querying events.
func (c *RepoLoaderConfigurator) MinVersion(version uint64) *RepoLoaderConfigurator {
c.loadOptions.lev.MinVersion = &version
return c
}
// MaxVersion sets the maximum version of the aggregate to load and returns the configurator.
// can be used to load a specific version of the aggregate
func (c *RepoLoaderConfigurator) MaxVersion(version uint64) *RepoLoaderConfigurator {
c.loadOptions.lev.MaxVersion = &version
return c
}
// EventTypes sets the event types to load and returns the configurator.
// NOTE: this will lead to inconsistent state if you're loading against an aggregate. Only use
// this if you're directly querying events.
func (c *RepoLoaderConfigurator) EventTypes(types ...string) *RepoLoaderConfigurator {
c.loadOptions.lev.EventTypes = types
return c
}
// FromTime sets the starting time from which to load events and returns the configurator.
// NOTE: this will lead to inconsistent state if you're loading against an aggregate. Only use
// this if you're directly querying events.
func (c *RepoLoaderConfigurator) FromTime(time time.Time) *RepoLoaderConfigurator {
c.loadOptions.lev.FromTime = &time
return c
}
// ToTime sets the ending time to which to load events and returns the configurator.
func (c *RepoLoaderConfigurator) ToTime(time time.Time) *RepoLoaderConfigurator {
c.loadOptions.lev.ToTime = &time
return c
}
// SkipSnapshot indicates to skip loading the snapshot during the operation and returns the configurator.
func (c *RepoLoaderConfigurator) SkipSnapshot(skip bool) *RepoLoaderConfigurator {
c.loadOptions.skipSnapshot = skip
return c
}
// Build finalizes the configuration and returns the configured RepoLoadOptions.
func (c *RepoLoaderConfigurator) Build() *RepoLoadOptions {
return &c.loadOptions
}