@@ -5,17 +5,13 @@ import (
55 "time"
66)
77
8- // ContextStrategy is an interface that represents strategy for providing contexts for running MongoDB requests
8+ // ContextStrategy is an interface that represents strategy for providing contexts for corresponding MongoDB EventStore
9+ // instance queries to MongoDB
910type ContextStrategy interface {
10- // Append is the context used for EventStore.Append() calls
1111 Append () (context.Context , context.CancelFunc )
12- // GetEventsFor is the context used for EventStore.GetEventsFor() calls
1312 GetEventsFor () (context.Context , context.CancelFunc )
14- // FromVersion is the context used for EventStore.FromVersion() calls
1513 FromVersion () (context.Context , context.CancelFunc )
16- // CountEventsFor is the context used for EventStore.CountEventsFor() calls
1714 CountEventsFor () (context.Context , context.CancelFunc )
18- // CreateIndices is the context used for MongoDB EventStore implementation indices creation
1915 CreateIndices () (context.Context , context.CancelFunc )
2016}
2117
@@ -29,27 +25,27 @@ func NewBackgroundContextStrategy() *BackgroundContextStrategy {
2925 return & BackgroundContextStrategy {ctx : context .Background ()}
3026}
3127
32- // Append is the context used for EventStore .Append() calls
28+ // Append is the ContextStrategy .Append() implementation
3329func (s * BackgroundContextStrategy ) Append () (context.Context , context.CancelFunc ) {
3430 return s .ctx , func () {}
3531}
3632
37- // GetEventsFor is the context used for EventStore .GetEventsFor() calls
33+ // GetEventsFor is the ContextStrategy .GetEventsFor() implementation
3834func (s * BackgroundContextStrategy ) GetEventsFor () (context.Context , context.CancelFunc ) {
3935 return s .ctx , func () {}
4036}
4137
42- // FromVersion is the context used for EventStore .FromVersion() calls
38+ // FromVersion is the ContextStrategy .FromVersion() implementation
4339func (s * BackgroundContextStrategy ) FromVersion () (context.Context , context.CancelFunc ) {
4440 return s .ctx , func () {}
4541}
4642
47- // CountEventsFor is the context used for EventStore .CountEventsFor() calls
43+ // CountEventsFor is the ContextStrategy .CountEventsFor() implementation
4844func (s * BackgroundContextStrategy ) CountEventsFor () (context.Context , context.CancelFunc ) {
4945 return s .ctx , func () {}
5046}
5147
52- // CreateIndices is the context used for MongoDB EventStore implementation indices creation
48+ // CreateIndices is the ContextStrategy.CreateIndices() implementation
5349func (s * BackgroundContextStrategy ) CreateIndices () (context.Context , context.CancelFunc ) {
5450 return s .ctx , func () {}
5551}
@@ -83,27 +79,27 @@ func NewTimeoutContextStrategy(options ...TimeoutContextStrategyOption) *Timeout
8379 return s
8480}
8581
86- // Append is the context used for EventStore .Append() calls
82+ // Append is the ContextStrategy .Append() implementation
8783func (s * TimeoutContextStrategy ) Append () (context.Context , context.CancelFunc ) {
8884 return context .WithTimeout (context .Background (), s .append )
8985}
9086
91- // GetEventsFor is the context used for EventStore .GetEventsFor() calls
87+ // GetEventsFor is the ContextStrategy .GetEventsFor() implementation
9288func (s * TimeoutContextStrategy ) GetEventsFor () (context.Context , context.CancelFunc ) {
9389 return context .WithTimeout (context .Background (), s .getEventsFor )
9490}
9591
96- // FromVersion is the context used for EventStore .FromVersion() calls
92+ // FromVersion is the ContextStrategy .FromVersion() implementation
9793func (s * TimeoutContextStrategy ) FromVersion () (context.Context , context.CancelFunc ) {
9894 return context .WithTimeout (context .Background (), s .fromVersion )
9995}
10096
101- // CountEventsFor is the context used for EventStore .CountEventsFor() calls
97+ // CountEventsFor is the ContextStrategy .CountEventsFor() implementation
10298func (s * TimeoutContextStrategy ) CountEventsFor () (context.Context , context.CancelFunc ) {
10399 return context .WithTimeout (context .Background (), s .countEventsFor )
104100}
105101
106- // CreateIndices is the context used for MongoDB EventStore implementation indices creation
102+ // CreateIndices is the ContextStrategy.CreateIndices() implementation
107103func (s * TimeoutContextStrategy ) CreateIndices () (context.Context , context.CancelFunc ) {
108104 return context .WithTimeout (context .Background (), s .createIndices )
109105}
0 commit comments