id
int32
0
167k
repo
stringlengths
5
54
path
stringlengths
4
155
func_name
stringlengths
1
118
original_string
stringlengths
52
85.5k
language
stringclasses
1 value
code
stringlengths
52
85.5k
code_tokens
list
docstring
stringlengths
6
2.61k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
85
252
19,400
looplab/eventhorizon
repo/version/repo.go
Repository
func Repository(repo eh.ReadRepo) *Repo { if repo == nil { return nil } if r, ok := repo.(*Repo); ok { return r } return Repository(repo.Parent()) }
go
func Repository(repo eh.ReadRepo) *Repo { if repo == nil { return nil } if r, ok := repo.(*Repo); ok { return r } return Repository(repo.Parent()) }
[ "func", "Repository", "(", "repo", "eh", ".", "ReadRepo", ")", "*", "Repo", "{", "if", "repo", "==", "nil", "{", "return", "nil", "\n", "}", "\n\n", "if", "r", ",", "ok", ":=", "repo", ".", "(", "*", "Repo", ")", ";", "ok", "{", "return", "r", ...
// Repository returns a parent ReadRepo if there is one.
[ "Repository", "returns", "a", "parent", "ReadRepo", "if", "there", "is", "one", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/version/repo.go#L111-L121
19,401
looplab/eventhorizon
repo/mongodb/repo.go
NewRepoWithSession
func NewRepoWithSession(session *mgo.Session, dbPrefix, collection string) (*Repo, error) { if session == nil { return nil, ErrNoDBSession } r := &Repo{ session: session, dbPrefix: dbPrefix, collection: collection, } return r, nil }
go
func NewRepoWithSession(session *mgo.Session, dbPrefix, collection string) (*Repo, error) { if session == nil { return nil, ErrNoDBSession } r := &Repo{ session: session, dbPrefix: dbPrefix, collection: collection, } return r, nil }
[ "func", "NewRepoWithSession", "(", "session", "*", "mgo", ".", "Session", ",", "dbPrefix", ",", "collection", "string", ")", "(", "*", "Repo", ",", "error", ")", "{", "if", "session", "==", "nil", "{", "return", "nil", ",", "ErrNoDBSession", "\n", "}", ...
// NewRepoWithSession creates a new Repo with a session.
[ "NewRepoWithSession", "creates", "a", "new", "Repo", "with", "a", "session", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/mongodb/repo.go#L64-L76
19,402
looplab/eventhorizon
repo/mongodb/repo.go
FindCustomIter
func (r *Repo) FindCustomIter(ctx context.Context, callback func(*mgo.Collection) *mgo.Query) (eh.Iter, error) { sess := r.session.Copy() if r.factoryFn == nil { return nil, eh.RepoError{ Err: ErrModelNotSet, Namespace: eh.NamespaceFromContext(ctx), } } collection := sess.DB(r.dbName(ctx)).C(r.col...
go
func (r *Repo) FindCustomIter(ctx context.Context, callback func(*mgo.Collection) *mgo.Query) (eh.Iter, error) { sess := r.session.Copy() if r.factoryFn == nil { return nil, eh.RepoError{ Err: ErrModelNotSet, Namespace: eh.NamespaceFromContext(ctx), } } collection := sess.DB(r.dbName(ctx)).C(r.col...
[ "func", "(", "r", "*", "Repo", ")", "FindCustomIter", "(", "ctx", "context", ".", "Context", ",", "callback", "func", "(", "*", "mgo", ".", "Collection", ")", "*", "mgo", ".", "Query", ")", "(", "eh", ".", "Iter", ",", "error", ")", "{", "sess", ...
// FindCustomIter returns a mgo cursor you can use to stream results of very large datasets
[ "FindCustomIter", "returns", "a", "mgo", "cursor", "you", "can", "use", "to", "stream", "results", "of", "very", "large", "datasets" ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/mongodb/repo.go#L163-L187
19,403
looplab/eventhorizon
repo/mongodb/repo.go
FindCustom
func (r *Repo) FindCustom(ctx context.Context, callback func(*mgo.Collection) *mgo.Query) ([]interface{}, error) { sess := r.session.Copy() defer sess.Close() if r.factoryFn == nil { return nil, eh.RepoError{ Err: ErrModelNotSet, Namespace: eh.NamespaceFromContext(ctx), } } collection := sess.DB(...
go
func (r *Repo) FindCustom(ctx context.Context, callback func(*mgo.Collection) *mgo.Query) ([]interface{}, error) { sess := r.session.Copy() defer sess.Close() if r.factoryFn == nil { return nil, eh.RepoError{ Err: ErrModelNotSet, Namespace: eh.NamespaceFromContext(ctx), } } collection := sess.DB(...
[ "func", "(", "r", "*", "Repo", ")", "FindCustom", "(", "ctx", "context", ".", "Context", ",", "callback", "func", "(", "*", "mgo", ".", "Collection", ")", "*", "mgo", ".", "Query", ")", "(", "[", "]", "interface", "{", "}", ",", "error", ")", "{"...
// FindCustom uses a callback to specify a custom query for returning models. // It can also be used to do queries that does not map to the model by executing // the query in the callback and returning nil to block a second execution of // the same query in FindCustom. Expect a ErrInvalidQuery if returning a nil // que...
[ "FindCustom", "uses", "a", "callback", "to", "specify", "a", "custom", "query", "for", "returning", "models", ".", "It", "can", "also", "be", "used", "to", "do", "queries", "that", "does", "not", "map", "to", "the", "model", "by", "executing", "the", "qu...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/mongodb/repo.go#L194-L229
19,404
looplab/eventhorizon
repo/mongodb/repo.go
Collection
func (r *Repo) Collection(ctx context.Context, f func(*mgo.Collection) error) error { sess := r.session.Copy() defer sess.Close() c := sess.DB(r.dbName(ctx)).C(r.collection) if err := f(c); err != nil { return eh.RepoError{ Err: err, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
go
func (r *Repo) Collection(ctx context.Context, f func(*mgo.Collection) error) error { sess := r.session.Copy() defer sess.Close() c := sess.DB(r.dbName(ctx)).C(r.collection) if err := f(c); err != nil { return eh.RepoError{ Err: err, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
[ "func", "(", "r", "*", "Repo", ")", "Collection", "(", "ctx", "context", ".", "Context", ",", "f", "func", "(", "*", "mgo", ".", "Collection", ")", "error", ")", "error", "{", "sess", ":=", "r", ".", "session", ".", "Copy", "(", ")", "\n", "defer...
// Collection lets the function do custom actions on the collection.
[ "Collection", "lets", "the", "function", "do", "custom", "actions", "on", "the", "collection", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/mongodb/repo.go#L273-L286
19,405
looplab/eventhorizon
repo/mongodb/repo.go
Clear
func (r *Repo) Clear(ctx context.Context) error { if err := r.session.DB(r.dbName(ctx)).C(r.collection).DropCollection(); err != nil { return eh.RepoError{ Err: ErrCouldNotClearDB, BaseErr: err, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
go
func (r *Repo) Clear(ctx context.Context) error { if err := r.session.DB(r.dbName(ctx)).C(r.collection).DropCollection(); err != nil { return eh.RepoError{ Err: ErrCouldNotClearDB, BaseErr: err, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
[ "func", "(", "r", "*", "Repo", ")", "Clear", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "err", ":=", "r", ".", "session", ".", "DB", "(", "r", ".", "dbName", "(", "ctx", ")", ")", ".", "C", "(", "r", ".", "collection", ")...
// Clear clears the read model database.
[ "Clear", "clears", "the", "read", "model", "database", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/mongodb/repo.go#L294-L303
19,406
looplab/eventhorizon
context.go
NamespaceFromContext
func NamespaceFromContext(ctx context.Context) string { if ns, ok := ctx.Value(namespaceKey).(string); ok { return ns } return DefaultNamespace }
go
func NamespaceFromContext(ctx context.Context) string { if ns, ok := ctx.Value(namespaceKey).(string); ok { return ns } return DefaultNamespace }
[ "func", "NamespaceFromContext", "(", "ctx", "context", ".", "Context", ")", "string", "{", "if", "ns", ",", "ok", ":=", "ctx", ".", "Value", "(", "namespaceKey", ")", ".", "(", "string", ")", ";", "ok", "{", "return", "ns", "\n", "}", "\n", "return",...
// NamespaceFromContext returns the namespace from the context, or the default // namespace.
[ "NamespaceFromContext", "returns", "the", "namespace", "from", "the", "context", "or", "the", "default", "namespace", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L78-L83
19,407
looplab/eventhorizon
context.go
NewContextWithNamespace
func NewContextWithNamespace(ctx context.Context, namespace string) context.Context { return context.WithValue(ctx, namespaceKey, namespace) }
go
func NewContextWithNamespace(ctx context.Context, namespace string) context.Context { return context.WithValue(ctx, namespaceKey, namespace) }
[ "func", "NewContextWithNamespace", "(", "ctx", "context", ".", "Context", ",", "namespace", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "namespaceKey", ",", "namespace", ")", "\n", "}" ]
// NewContextWithNamespace sets the namespace to use in the context. The // namespace is used to determine which database.
[ "NewContextWithNamespace", "sets", "the", "namespace", "to", "use", "in", "the", "context", ".", "The", "namespace", "is", "used", "to", "determine", "which", "database", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L87-L89
19,408
looplab/eventhorizon
context.go
MinVersionFromContext
func MinVersionFromContext(ctx context.Context) (int, bool) { minVersion, ok := ctx.Value(minVersionKey).(int) return minVersion, ok }
go
func MinVersionFromContext(ctx context.Context) (int, bool) { minVersion, ok := ctx.Value(minVersionKey).(int) return minVersion, ok }
[ "func", "MinVersionFromContext", "(", "ctx", "context", ".", "Context", ")", "(", "int", ",", "bool", ")", "{", "minVersion", ",", "ok", ":=", "ctx", ".", "Value", "(", "minVersionKey", ")", ".", "(", "int", ")", "\n", "return", "minVersion", ",", "ok"...
// MinVersionFromContext returns the min version from the context.
[ "MinVersionFromContext", "returns", "the", "min", "version", "from", "the", "context", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L92-L95
19,409
looplab/eventhorizon
context.go
NewContextWithMinVersion
func NewContextWithMinVersion(ctx context.Context, minVersion int) context.Context { return context.WithValue(ctx, minVersionKey, minVersion) }
go
func NewContextWithMinVersion(ctx context.Context, minVersion int) context.Context { return context.WithValue(ctx, minVersionKey, minVersion) }
[ "func", "NewContextWithMinVersion", "(", "ctx", "context", ".", "Context", ",", "minVersion", "int", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "minVersionKey", ",", "minVersion", ")", "\n", "}" ]
// NewContextWithMinVersion returns the context with min version set.
[ "NewContextWithMinVersion", "returns", "the", "context", "with", "min", "version", "set", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L98-L100
19,410
looplab/eventhorizon
context.go
NewContextWithMinVersionWait
func NewContextWithMinVersionWait(ctx context.Context, minVersion int) (c context.Context, cancel func()) { ctx = context.WithValue(ctx, minVersionKey, minVersion) return context.WithTimeout(ctx, DefaultMinVersionDeadline) }
go
func NewContextWithMinVersionWait(ctx context.Context, minVersion int) (c context.Context, cancel func()) { ctx = context.WithValue(ctx, minVersionKey, minVersion) return context.WithTimeout(ctx, DefaultMinVersionDeadline) }
[ "func", "NewContextWithMinVersionWait", "(", "ctx", "context", ".", "Context", ",", "minVersion", "int", ")", "(", "c", "context", ".", "Context", ",", "cancel", "func", "(", ")", ")", "{", "ctx", "=", "context", ".", "WithValue", "(", "ctx", ",", "minVe...
// NewContextWithMinVersionWait returns the context with min version and a // default deadline set.
[ "NewContextWithMinVersionWait", "returns", "the", "context", "with", "min", "version", "and", "a", "default", "deadline", "set", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L104-L107
19,411
looplab/eventhorizon
context.go
RegisterContextMarshaler
func RegisterContextMarshaler(f ContextMarshalFunc) { contextMarshalFuncsMu.Lock() defer contextMarshalFuncsMu.Unlock() contextMarshalFuncs = append(contextMarshalFuncs, f) }
go
func RegisterContextMarshaler(f ContextMarshalFunc) { contextMarshalFuncsMu.Lock() defer contextMarshalFuncsMu.Unlock() contextMarshalFuncs = append(contextMarshalFuncs, f) }
[ "func", "RegisterContextMarshaler", "(", "f", "ContextMarshalFunc", ")", "{", "contextMarshalFuncsMu", ".", "Lock", "(", ")", "\n", "defer", "contextMarshalFuncsMu", ".", "Unlock", "(", ")", "\n", "contextMarshalFuncs", "=", "append", "(", "contextMarshalFuncs", ","...
// RegisterContextMarshaler registers a marshaler function used by MarshalContext.
[ "RegisterContextMarshaler", "registers", "a", "marshaler", "function", "used", "by", "MarshalContext", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L123-L127
19,412
looplab/eventhorizon
context.go
MarshalContext
func MarshalContext(ctx context.Context) map[string]interface{} { contextMarshalFuncsMu.RLock() defer contextMarshalFuncsMu.RUnlock() allVals := map[string]interface{}{} for _, f := range contextMarshalFuncs { vals := map[string]interface{}{} f(ctx, vals) for key, val := range vals { if _, ok := allVals...
go
func MarshalContext(ctx context.Context) map[string]interface{} { contextMarshalFuncsMu.RLock() defer contextMarshalFuncsMu.RUnlock() allVals := map[string]interface{}{} for _, f := range contextMarshalFuncs { vals := map[string]interface{}{} f(ctx, vals) for key, val := range vals { if _, ok := allVals...
[ "func", "MarshalContext", "(", "ctx", "context", ".", "Context", ")", "map", "[", "string", "]", "interface", "{", "}", "{", "contextMarshalFuncsMu", ".", "RLock", "(", ")", "\n", "defer", "contextMarshalFuncsMu", ".", "RUnlock", "(", ")", "\n\n", "allVals",...
// MarshalContext marshals a context into a map.
[ "MarshalContext", "marshals", "a", "context", "into", "a", "map", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L130-L149
19,413
looplab/eventhorizon
context.go
RegisterContextUnmarshaler
func RegisterContextUnmarshaler(f ContextUnmarshalFunc) { contextUnmarshalFuncsMu.Lock() defer contextUnmarshalFuncsMu.Unlock() contextUnmarshalFuncs = append(contextUnmarshalFuncs, f) }
go
func RegisterContextUnmarshaler(f ContextUnmarshalFunc) { contextUnmarshalFuncsMu.Lock() defer contextUnmarshalFuncsMu.Unlock() contextUnmarshalFuncs = append(contextUnmarshalFuncs, f) }
[ "func", "RegisterContextUnmarshaler", "(", "f", "ContextUnmarshalFunc", ")", "{", "contextUnmarshalFuncsMu", ".", "Lock", "(", ")", "\n", "defer", "contextUnmarshalFuncsMu", ".", "Unlock", "(", ")", "\n", "contextUnmarshalFuncs", "=", "append", "(", "contextUnmarshalF...
// RegisterContextUnmarshaler registers a marshaler function used by UnmarshalContext.
[ "RegisterContextUnmarshaler", "registers", "a", "marshaler", "function", "used", "by", "UnmarshalContext", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L156-L160
19,414
looplab/eventhorizon
context.go
UnmarshalContext
func UnmarshalContext(vals map[string]interface{}) context.Context { contextUnmarshalFuncsMu.RLock() defer contextUnmarshalFuncsMu.RUnlock() ctx := context.Background() if vals == nil { return ctx } for _, f := range contextUnmarshalFuncs { ctx = f(ctx, vals) } return ctx }
go
func UnmarshalContext(vals map[string]interface{}) context.Context { contextUnmarshalFuncsMu.RLock() defer contextUnmarshalFuncsMu.RUnlock() ctx := context.Background() if vals == nil { return ctx } for _, f := range contextUnmarshalFuncs { ctx = f(ctx, vals) } return ctx }
[ "func", "UnmarshalContext", "(", "vals", "map", "[", "string", "]", "interface", "{", "}", ")", "context", ".", "Context", "{", "contextUnmarshalFuncsMu", ".", "RLock", "(", ")", "\n", "defer", "contextUnmarshalFuncsMu", ".", "RUnlock", "(", ")", "\n\n", "ct...
// UnmarshalContext unmarshals a context from a map.
[ "UnmarshalContext", "unmarshals", "a", "context", "from", "a", "map", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/context.go#L163-L177
19,415
looplab/eventhorizon
middleware/commandhandler/validator/commandhandler.go
NewMiddleware
func NewMiddleware() eh.CommandHandlerMiddleware { return eh.CommandHandlerMiddleware(func(h eh.CommandHandler) eh.CommandHandler { return eh.CommandHandlerFunc(func(ctx context.Context, cmd eh.Command) error { // Call the validation method if it exists if c, ok := cmd.(Command); ok { err := c.Validate() ...
go
func NewMiddleware() eh.CommandHandlerMiddleware { return eh.CommandHandlerMiddleware(func(h eh.CommandHandler) eh.CommandHandler { return eh.CommandHandlerFunc(func(ctx context.Context, cmd eh.Command) error { // Call the validation method if it exists if c, ok := cmd.(Command); ok { err := c.Validate() ...
[ "func", "NewMiddleware", "(", ")", "eh", ".", "CommandHandlerMiddleware", "{", "return", "eh", ".", "CommandHandlerMiddleware", "(", "func", "(", "h", "eh", ".", "CommandHandler", ")", "eh", ".", "CommandHandler", "{", "return", "eh", ".", "CommandHandlerFunc", ...
// NewMiddleware returns a new async handling middleware that validate commands // with its own validation method.
[ "NewMiddleware", "returns", "a", "new", "async", "handling", "middleware", "that", "validate", "commands", "with", "its", "own", "validation", "method", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/middleware/commandhandler/validator/commandhandler.go#L25-L40
19,416
looplab/eventhorizon
middleware/commandhandler/validator/commandhandler.go
CommandWithValidation
func CommandWithValidation(cmd eh.Command, v func() error) Command { return &command{Command: cmd, validate: v} }
go
func CommandWithValidation(cmd eh.Command, v func() error) Command { return &command{Command: cmd, validate: v} }
[ "func", "CommandWithValidation", "(", "cmd", "eh", ".", "Command", ",", "v", "func", "(", ")", "error", ")", "Command", "{", "return", "&", "command", "{", "Command", ":", "cmd", ",", "validate", ":", "v", "}", "\n", "}" ]
// CommandWithValidation returns a wrapped command with a validation method.
[ "CommandWithValidation", "returns", "a", "wrapped", "command", "with", "a", "validation", "method", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/middleware/commandhandler/validator/commandhandler.go#L51-L53
19,417
looplab/eventhorizon
mocks/mocks.go
NewAggregate
func NewAggregate(id uuid.UUID) *Aggregate { return &Aggregate{ ID: id, Commands: []eh.Command{}, } }
go
func NewAggregate(id uuid.UUID) *Aggregate { return &Aggregate{ ID: id, Commands: []eh.Command{}, } }
[ "func", "NewAggregate", "(", "id", "uuid", ".", "UUID", ")", "*", "Aggregate", "{", "return", "&", "Aggregate", "{", "ID", ":", "id", ",", "Commands", ":", "[", "]", "eh", ".", "Command", "{", "}", ",", "}", "\n", "}" ]
// NewAggregate returns a new Aggregate.
[ "NewAggregate", "returns", "a", "new", "Aggregate", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L66-L71
19,418
looplab/eventhorizon
mocks/mocks.go
HandleCommand
func (a *Aggregate) HandleCommand(ctx context.Context, cmd eh.Command) error { if a.Err != nil { return a.Err } a.Commands = append(a.Commands, cmd) a.Context = ctx return nil }
go
func (a *Aggregate) HandleCommand(ctx context.Context, cmd eh.Command) error { if a.Err != nil { return a.Err } a.Commands = append(a.Commands, cmd) a.Context = ctx return nil }
[ "func", "(", "a", "*", "Aggregate", ")", "HandleCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "eh", ".", "Command", ")", "error", "{", "if", "a", ".", "Err", "!=", "nil", "{", "return", "a", ".", "Err", "\n", "}", "\n", "a", ".", ...
// HandleCommand implements the HandleCommand method of the eventhorizon.Aggregate interface.
[ "HandleCommand", "implements", "the", "HandleCommand", "method", "of", "the", "eventhorizon", ".", "Aggregate", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L86-L93
19,419
looplab/eventhorizon
mocks/mocks.go
Reset
func (m *EventHandler) Reset() { m.Events = []eh.Event{} m.Context = context.Background() m.Time = time.Time{} }
go
func (m *EventHandler) Reset() { m.Events = []eh.Event{} m.Context = context.Background() m.Time = time.Time{} }
[ "func", "(", "m", "*", "EventHandler", ")", "Reset", "(", ")", "{", "m", ".", "Events", "=", "[", "]", "eh", ".", "Event", "{", "}", "\n", "m", ".", "Context", "=", "context", ".", "Background", "(", ")", "\n", "m", ".", "Time", "=", "time", ...
// Reset resets the mock data.
[ "Reset", "resets", "the", "mock", "data", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L231-L235
19,420
looplab/eventhorizon
mocks/mocks.go
Wait
func (m *EventHandler) Wait(d time.Duration) bool { select { case <-m.Recv: return true case <-time.After(d): return false } }
go
func (m *EventHandler) Wait(d time.Duration) bool { select { case <-m.Recv: return true case <-time.After(d): return false } }
[ "func", "(", "m", "*", "EventHandler", ")", "Wait", "(", "d", "time", ".", "Duration", ")", "bool", "{", "select", "{", "case", "<-", "m", ".", "Recv", ":", "return", "true", "\n", "case", "<-", "time", ".", "After", "(", "d", ")", ":", "return",...
// Wait is a helper to wait some duration until for an event to be handled.
[ "Wait", "is", "a", "helper", "to", "wait", "some", "duration", "until", "for", "an", "event", "to", "be", "handled", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L238-L245
19,421
looplab/eventhorizon
mocks/mocks.go
Load
func (m *AggregateStore) Load(ctx context.Context, aggregateType eh.AggregateType, id uuid.UUID) (eh.Aggregate, error) { if m.Err != nil { return nil, m.Err } m.Context = ctx return m.Aggregates[id], nil }
go
func (m *AggregateStore) Load(ctx context.Context, aggregateType eh.AggregateType, id uuid.UUID) (eh.Aggregate, error) { if m.Err != nil { return nil, m.Err } m.Context = ctx return m.Aggregates[id], nil }
[ "func", "(", "m", "*", "AggregateStore", ")", "Load", "(", "ctx", "context", ".", "Context", ",", "aggregateType", "eh", ".", "AggregateType", ",", "id", "uuid", ".", "UUID", ")", "(", "eh", ".", "Aggregate", ",", "error", ")", "{", "if", "m", ".", ...
// Load implements the Load method of the eventhorizon.AggregateStore interface.
[ "Load", "implements", "the", "Load", "method", "of", "the", "eventhorizon", ".", "AggregateStore", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L258-L264
19,422
looplab/eventhorizon
mocks/mocks.go
Save
func (m *AggregateStore) Save(ctx context.Context, aggregate eh.Aggregate) error { if m.Err != nil { return m.Err } m.Context = ctx m.Aggregates[aggregate.EntityID()] = aggregate return nil }
go
func (m *AggregateStore) Save(ctx context.Context, aggregate eh.Aggregate) error { if m.Err != nil { return m.Err } m.Context = ctx m.Aggregates[aggregate.EntityID()] = aggregate return nil }
[ "func", "(", "m", "*", "AggregateStore", ")", "Save", "(", "ctx", "context", ".", "Context", ",", "aggregate", "eh", ".", "Aggregate", ")", "error", "{", "if", "m", ".", "Err", "!=", "nil", "{", "return", "m", ".", "Err", "\n", "}", "\n", "m", "....
// Save implements the Save method of the eventhorizon.AggregateStore interface.
[ "Save", "implements", "the", "Save", "method", "of", "the", "eventhorizon", ".", "AggregateStore", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L267-L274
19,423
looplab/eventhorizon
mocks/mocks.go
Save
func (r *Repo) Save(ctx context.Context, entity eh.Entity) error { r.SaveCalled = true if r.SaveErr != nil { return r.SaveErr } r.Entity = entity return nil }
go
func (r *Repo) Save(ctx context.Context, entity eh.Entity) error { r.SaveCalled = true if r.SaveErr != nil { return r.SaveErr } r.Entity = entity return nil }
[ "func", "(", "r", "*", "Repo", ")", "Save", "(", "ctx", "context", ".", "Context", ",", "entity", "eh", ".", "Entity", ")", "error", "{", "r", ".", "SaveCalled", "=", "true", "\n", "if", "r", ".", "SaveErr", "!=", "nil", "{", "return", "r", ".", ...
// Save implements the Save method of the eventhorizon.ReadRepo interface.
[ "Save", "implements", "the", "Save", "method", "of", "the", "eventhorizon", ".", "ReadRepo", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L387-L394
19,424
looplab/eventhorizon
mocks/mocks.go
Remove
func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error { r.RemoveCalled = true if r.SaveErr != nil { return r.SaveErr } r.Entity = nil return nil }
go
func (r *Repo) Remove(ctx context.Context, id uuid.UUID) error { r.RemoveCalled = true if r.SaveErr != nil { return r.SaveErr } r.Entity = nil return nil }
[ "func", "(", "r", "*", "Repo", ")", "Remove", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ")", "error", "{", "r", ".", "RemoveCalled", "=", "true", "\n", "if", "r", ".", "SaveErr", "!=", "nil", "{", "return", "r", ".", ...
// Remove implements the Remove method of the eventhorizon.ReadRepo interface.
[ "Remove", "implements", "the", "Remove", "method", "of", "the", "eventhorizon", ".", "ReadRepo", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L397-L404
19,425
looplab/eventhorizon
mocks/mocks.go
WithContextOne
func WithContextOne(ctx context.Context, val string) context.Context { return context.WithValue(ctx, contextKeyOne, val) }
go
func WithContextOne(ctx context.Context, val string) context.Context { return context.WithValue(ctx, contextKeyOne, val) }
[ "func", "WithContextOne", "(", "ctx", "context", ".", "Context", ",", "val", "string", ")", "context", ".", "Context", "{", "return", "context", ".", "WithValue", "(", "ctx", ",", "contextKeyOne", ",", "val", ")", "\n", "}" ]
// WithContextOne sets a value for One one the context.
[ "WithContextOne", "sets", "a", "value", "for", "One", "one", "the", "context", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L413-L415
19,426
looplab/eventhorizon
mocks/mocks.go
ContextOne
func ContextOne(ctx context.Context) (string, bool) { val, ok := ctx.Value(contextKeyOne).(string) return val, ok }
go
func ContextOne(ctx context.Context) (string, bool) { val, ok := ctx.Value(contextKeyOne).(string) return val, ok }
[ "func", "ContextOne", "(", "ctx", "context", ".", "Context", ")", "(", "string", ",", "bool", ")", "{", "val", ",", "ok", ":=", "ctx", ".", "Value", "(", "contextKeyOne", ")", ".", "(", "string", ")", "\n", "return", "val", ",", "ok", "\n", "}" ]
// ContextOne returns a value for One from the context.
[ "ContextOne", "returns", "a", "value", "for", "One", "from", "the", "context", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L418-L421
19,427
looplab/eventhorizon
mocks/mocks.go
init
func init() { eh.RegisterContextMarshaler(func(ctx context.Context, vals map[string]interface{}) { if val, ok := ContextOne(ctx); ok { vals[contextKeyOneStr] = val } }) eh.RegisterContextUnmarshaler(func(ctx context.Context, vals map[string]interface{}) context.Context { if val, ok := vals[contextKeyOneStr]...
go
func init() { eh.RegisterContextMarshaler(func(ctx context.Context, vals map[string]interface{}) { if val, ok := ContextOne(ctx); ok { vals[contextKeyOneStr] = val } }) eh.RegisterContextUnmarshaler(func(ctx context.Context, vals map[string]interface{}) context.Context { if val, ok := vals[contextKeyOneStr]...
[ "func", "init", "(", ")", "{", "eh", ".", "RegisterContextMarshaler", "(", "func", "(", "ctx", "context", ".", "Context", ",", "vals", "map", "[", "string", "]", "interface", "{", "}", ")", "{", "if", "val", ",", "ok", ":=", "ContextOne", "(", "ctx",...
// Register the marshalers and unmarshalers for ContextOne.
[ "Register", "the", "marshalers", "and", "unmarshalers", "for", "ContextOne", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/mocks/mocks.go#L429-L441
19,428
looplab/eventhorizon
eventbus/local/eventbus.go
NewEventBus
func NewEventBus(g *Group) *EventBus { if g == nil { g = NewGroup() } return &EventBus{ group: g, registered: map[eh.EventHandlerType]struct{}{}, errCh: make(chan eh.EventBusError, 100), } }
go
func NewEventBus(g *Group) *EventBus { if g == nil { g = NewGroup() } return &EventBus{ group: g, registered: map[eh.EventHandlerType]struct{}{}, errCh: make(chan eh.EventBusError, 100), } }
[ "func", "NewEventBus", "(", "g", "*", "Group", ")", "*", "EventBus", "{", "if", "g", "==", "nil", "{", "g", "=", "NewGroup", "(", ")", "\n", "}", "\n", "return", "&", "EventBus", "{", "group", ":", "g", ",", "registered", ":", "map", "[", "eh", ...
// NewEventBus creates a EventBus.
[ "NewEventBus", "creates", "a", "EventBus", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/local/eventbus.go#L40-L49
19,429
looplab/eventhorizon
eventbus/local/eventbus.go
channel
func (b *EventBus) channel(m eh.EventMatcher, h eh.EventHandler, observer bool) <-chan evt { b.registeredMu.Lock() defer b.registeredMu.Unlock() if m == nil { panic("matcher can't be nil") } if h == nil { panic("handler can't be nil") } if _, ok := b.registered[h.HandlerType()]; ok { panic(fmt.Sprintf("mu...
go
func (b *EventBus) channel(m eh.EventMatcher, h eh.EventHandler, observer bool) <-chan evt { b.registeredMu.Lock() defer b.registeredMu.Unlock() if m == nil { panic("matcher can't be nil") } if h == nil { panic("handler can't be nil") } if _, ok := b.registered[h.HandlerType()]; ok { panic(fmt.Sprintf("mu...
[ "func", "(", "b", "*", "EventBus", ")", "channel", "(", "m", "eh", ".", "EventMatcher", ",", "h", "eh", ".", "EventHandler", ",", "observer", "bool", ")", "<-", "chan", "evt", "{", "b", ".", "registeredMu", ".", "Lock", "(", ")", "\n", "defer", "b"...
// Checks the matcher and handler and gets the event channel from the group.
[ "Checks", "the", "matcher", "and", "handler", "and", "gets", "the", "event", "channel", "from", "the", "group", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/local/eventbus.go#L93-L113
19,430
looplab/eventhorizon
eventbus/local/eventbus.go
Close
func (g *Group) Close() { for _, ch := range g.bus { close(ch) } g.bus = nil }
go
func (g *Group) Close() { for _, ch := range g.bus { close(ch) } g.bus = nil }
[ "func", "(", "g", "*", "Group", ")", "Close", "(", ")", "{", "for", "_", ",", "ch", ":=", "range", "g", ".", "bus", "{", "close", "(", "ch", ")", "\n", "}", "\n", "g", ".", "bus", "=", "nil", "\n", "}" ]
// Close all the open channels
[ "Close", "all", "the", "open", "channels" ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/local/eventbus.go#L170-L175
19,431
looplab/eventhorizon
middleware/commandhandler/scheduler/commandhandler.go
CommandWithExecuteTime
func CommandWithExecuteTime(cmd eh.Command, t time.Time) Command { return &command{Command: cmd, t: t} }
go
func CommandWithExecuteTime(cmd eh.Command, t time.Time) Command { return &command{Command: cmd, t: t} }
[ "func", "CommandWithExecuteTime", "(", "cmd", "eh", ".", "Command", ",", "t", "time", ".", "Time", ")", "Command", "{", "return", "&", "command", "{", "Command", ":", "cmd", ",", "t", ":", "t", "}", "\n", "}" ]
// CommandWithExecuteTime returns a wrapped command with a execution time set.
[ "CommandWithExecuteTime", "returns", "a", "wrapped", "command", "with", "a", "execution", "time", "set", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/middleware/commandhandler/scheduler/commandhandler.go#L68-L70
19,432
looplab/eventhorizon
examples/guestlist/domain/saga.go
NewResponseSaga
func NewResponseSaga(guestLimit int) *ResponseSaga { return &ResponseSaga{ acceptedGuests: map[uuid.UUID]bool{}, guestLimit: guestLimit, } }
go
func NewResponseSaga(guestLimit int) *ResponseSaga { return &ResponseSaga{ acceptedGuests: map[uuid.UUID]bool{}, guestLimit: guestLimit, } }
[ "func", "NewResponseSaga", "(", "guestLimit", "int", ")", "*", "ResponseSaga", "{", "return", "&", "ResponseSaga", "{", "acceptedGuests", ":", "map", "[", "uuid", ".", "UUID", "]", "bool", "{", "}", ",", "guestLimit", ":", "guestLimit", ",", "}", "\n", "...
// NewResponseSaga returns a new ResponseSage with a guest limit.
[ "NewResponseSaga", "returns", "a", "new", "ResponseSage", "with", "a", "guest", "limit", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/saga.go#L38-L43
19,433
looplab/eventhorizon
examples/guestlist/domain/saga.go
RunSaga
func (s *ResponseSaga) RunSaga(ctx context.Context, event eh.Event) []eh.Command { switch event.EventType() { case InviteAcceptedEvent: // Do nothing for already accepted guests. s.acceptedGuestsMu.RLock() ok, _ := s.acceptedGuests[event.AggregateID()] s.acceptedGuestsMu.RUnlock() if ok { return nil } ...
go
func (s *ResponseSaga) RunSaga(ctx context.Context, event eh.Event) []eh.Command { switch event.EventType() { case InviteAcceptedEvent: // Do nothing for already accepted guests. s.acceptedGuestsMu.RLock() ok, _ := s.acceptedGuests[event.AggregateID()] s.acceptedGuestsMu.RUnlock() if ok { return nil } ...
[ "func", "(", "s", "*", "ResponseSaga", ")", "RunSaga", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "[", "]", "eh", ".", "Command", "{", "switch", "event", ".", "EventType", "(", ")", "{", "case", "InviteAcceptedEvent",...
// RunSaga implements the Run saga method of the Saga interface.
[ "RunSaga", "implements", "the", "Run", "saga", "method", "of", "the", "Saga", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/saga.go#L51-L80
19,434
looplab/eventhorizon
examples/guestlist/domain/logger.go
LoggingMiddleware
func LoggingMiddleware(h eh.CommandHandler) eh.CommandHandler { return eh.CommandHandlerFunc(func(ctx context.Context, cmd eh.Command) error { log.Printf("command: %#v", cmd) return h.HandleCommand(ctx, cmd) }) }
go
func LoggingMiddleware(h eh.CommandHandler) eh.CommandHandler { return eh.CommandHandlerFunc(func(ctx context.Context, cmd eh.Command) error { log.Printf("command: %#v", cmd) return h.HandleCommand(ctx, cmd) }) }
[ "func", "LoggingMiddleware", "(", "h", "eh", ".", "CommandHandler", ")", "eh", ".", "CommandHandler", "{", "return", "eh", ".", "CommandHandlerFunc", "(", "func", "(", "ctx", "context", ".", "Context", ",", "cmd", "eh", ".", "Command", ")", "error", "{", ...
// LoggingMiddleware is a tiny command handle middleware for logging.
[ "LoggingMiddleware", "is", "a", "tiny", "command", "handle", "middleware", "for", "logging", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/logger.go#L25-L30
19,435
looplab/eventhorizon
repo/cache/repo.go
Notify
func (r *Repo) Notify(ctx context.Context, event eh.Event) { // Bust the cache on entity updates. ns := r.namespace(ctx) r.cacheMu.Lock() delete(r.cache[ns], event.AggregateID()) r.cacheMu.Unlock() }
go
func (r *Repo) Notify(ctx context.Context, event eh.Event) { // Bust the cache on entity updates. ns := r.namespace(ctx) r.cacheMu.Lock() delete(r.cache[ns], event.AggregateID()) r.cacheMu.Unlock() }
[ "func", "(", "r", "*", "Repo", ")", "Notify", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "{", "// Bust the cache on entity updates.", "ns", ":=", "r", ".", "namespace", "(", "ctx", ")", "\n", "r", ".", "cacheMu", ".",...
// Notify implements the Notify method of the eventhorizon.Observer interface.
[ "Notify", "implements", "the", "Notify", "method", "of", "the", "eventhorizon", ".", "Observer", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/cache/repo.go#L47-L53
19,436
looplab/eventhorizon
repo/cache/repo.go
Find
func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error) { ns := r.namespace(ctx) // First check the cache. r.cacheMu.RLock() entity, ok := r.cache[ns][id] r.cacheMu.RUnlock() if ok { return entity, nil } // Fetch and store the entity in the cache. entity, err := r.ReadWriteRepo.Find(ctx, ...
go
func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error) { ns := r.namespace(ctx) // First check the cache. r.cacheMu.RLock() entity, ok := r.cache[ns][id] r.cacheMu.RUnlock() if ok { return entity, nil } // Fetch and store the entity in the cache. entity, err := r.ReadWriteRepo.Find(ctx, ...
[ "func", "(", "r", "*", "Repo", ")", "Find", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ")", "(", "eh", ".", "Entity", ",", "error", ")", "{", "ns", ":=", "r", ".", "namespace", "(", "ctx", ")", "\n\n", "// First check ...
// Find implements the Find method of the eventhorizon.ReadModel interface.
[ "Find", "implements", "the", "Find", "method", "of", "the", "eventhorizon", ".", "ReadModel", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/cache/repo.go#L61-L82
19,437
looplab/eventhorizon
commandhandler/aggregate/commandhandler.go
NewCommandHandler
func NewCommandHandler(t eh.AggregateType, store eh.AggregateStore) (*CommandHandler, error) { if store == nil { return nil, ErrNilAggregateStore } h := &CommandHandler{ t: t, store: store, } return h, nil }
go
func NewCommandHandler(t eh.AggregateType, store eh.AggregateStore) (*CommandHandler, error) { if store == nil { return nil, ErrNilAggregateStore } h := &CommandHandler{ t: t, store: store, } return h, nil }
[ "func", "NewCommandHandler", "(", "t", "eh", ".", "AggregateType", ",", "store", "eh", ".", "AggregateStore", ")", "(", "*", "CommandHandler", ",", "error", ")", "{", "if", "store", "==", "nil", "{", "return", "nil", ",", "ErrNilAggregateStore", "\n", "}",...
// NewCommandHandler creates a new CommandHandler for an aggregate type.
[ "NewCommandHandler", "creates", "a", "new", "CommandHandler", "for", "an", "aggregate", "type", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler/aggregate/commandhandler.go#L42-L52
19,438
looplab/eventhorizon
commandhandler/aggregate/commandhandler.go
HandleCommand
func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eh.Command) error { err := eh.CheckCommand(cmd) if err != nil { return err } a, err := h.store.Load(ctx, h.t, cmd.AggregateID()) if err != nil { return err } else if a == nil { return eh.ErrAggregateNotFound } if err = a.HandleCommand(ctx, ...
go
func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eh.Command) error { err := eh.CheckCommand(cmd) if err != nil { return err } a, err := h.store.Load(ctx, h.t, cmd.AggregateID()) if err != nil { return err } else if a == nil { return eh.ErrAggregateNotFound } if err = a.HandleCommand(ctx, ...
[ "func", "(", "h", "*", "CommandHandler", ")", "HandleCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "eh", ".", "Command", ")", "error", "{", "err", ":=", "eh", ".", "CheckCommand", "(", "cmd", ")", "\n", "if", "err", "!=", "nil", "{", ...
// HandleCommand handles a command with the registered aggregate. // Returns ErrAggregateNotFound if no aggregate could be found.
[ "HandleCommand", "handles", "a", "command", "with", "the", "registered", "aggregate", ".", "Returns", "ErrAggregateNotFound", "if", "no", "aggregate", "could", "be", "found", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler/aggregate/commandhandler.go#L56-L74
19,439
looplab/eventhorizon
event.go
NewEvent
func NewEvent(eventType EventType, data EventData, timestamp time.Time) Event { return event{ eventType: eventType, data: data, timestamp: timestamp, } }
go
func NewEvent(eventType EventType, data EventData, timestamp time.Time) Event { return event{ eventType: eventType, data: data, timestamp: timestamp, } }
[ "func", "NewEvent", "(", "eventType", "EventType", ",", "data", "EventData", ",", "timestamp", "time", ".", "Time", ")", "Event", "{", "return", "event", "{", "eventType", ":", "eventType", ",", "data", ":", "data", ",", "timestamp", ":", "timestamp", ",",...
// NewEvent creates a new event with a type and data, setting its timestamp.
[ "NewEvent", "creates", "a", "new", "event", "with", "a", "type", "and", "data", "setting", "its", "timestamp", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/event.go#L62-L68
19,440
looplab/eventhorizon
event.go
NewEventForAggregate
func NewEventForAggregate(eventType EventType, data EventData, timestamp time.Time, aggregateType AggregateType, aggregateID uuid.UUID, version int) Event { return event{ eventType: eventType, data: data, timestamp: timestamp, aggregateType: aggregateType, aggregateID: aggregateID, vers...
go
func NewEventForAggregate(eventType EventType, data EventData, timestamp time.Time, aggregateType AggregateType, aggregateID uuid.UUID, version int) Event { return event{ eventType: eventType, data: data, timestamp: timestamp, aggregateType: aggregateType, aggregateID: aggregateID, vers...
[ "func", "NewEventForAggregate", "(", "eventType", "EventType", ",", "data", "EventData", ",", "timestamp", "time", ".", "Time", ",", "aggregateType", "AggregateType", ",", "aggregateID", "uuid", ".", "UUID", ",", "version", "int", ")", "Event", "{", "return", ...
// NewEventForAggregate creates a new event with a type and data, setting its // timestamp. It also sets the aggregate data on it.
[ "NewEventForAggregate", "creates", "a", "new", "event", "with", "a", "type", "and", "data", "setting", "its", "timestamp", ".", "It", "also", "sets", "the", "aggregate", "data", "on", "it", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/event.go#L72-L82
19,441
looplab/eventhorizon
event.go
String
func (e event) String() string { return fmt.Sprintf("%s@%d", e.eventType, e.version) }
go
func (e event) String() string { return fmt.Sprintf("%s@%d", e.eventType, e.version) }
[ "func", "(", "e", "event", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "eventType", ",", "e", ".", "version", ")", "\n", "}" ]
// String implements the String method of the Event interface.
[ "String", "implements", "the", "String", "method", "of", "the", "Event", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/event.go#L127-L129
19,442
looplab/eventhorizon
event.go
UnregisterEventData
func UnregisterEventData(eventType EventType) { if eventType == EventType("") { panic("eventhorizon: attempt to unregister empty event type") } eventDataFactoriesMu.Lock() defer eventDataFactoriesMu.Unlock() if _, ok := eventDataFactories[eventType]; !ok { panic(fmt.Sprintf("eventhorizon: unregister of non-re...
go
func UnregisterEventData(eventType EventType) { if eventType == EventType("") { panic("eventhorizon: attempt to unregister empty event type") } eventDataFactoriesMu.Lock() defer eventDataFactoriesMu.Unlock() if _, ok := eventDataFactories[eventType]; !ok { panic(fmt.Sprintf("eventhorizon: unregister of non-re...
[ "func", "UnregisterEventData", "(", "eventType", "EventType", ")", "{", "if", "eventType", "==", "EventType", "(", "\"", "\"", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "eventDataFactoriesMu", ".", "Lock", "(", ")", "\n", "defer", "even...
// UnregisterEventData removes the registration of the event data factory for // a type. This is mainly useful in mainenance situations where the event data // needs to be switched in a migrations.
[ "UnregisterEventData", "removes", "the", "registration", "of", "the", "event", "data", "factory", "for", "a", "type", ".", "This", "is", "mainly", "useful", "in", "mainenance", "situations", "where", "the", "event", "data", "needs", "to", "be", "switched", "in...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/event.go#L161-L172
19,443
looplab/eventhorizon
event.go
CreateEventData
func CreateEventData(eventType EventType) (EventData, error) { eventDataFactoriesMu.RLock() defer eventDataFactoriesMu.RUnlock() if factory, ok := eventDataFactories[eventType]; ok { return factory(), nil } return nil, ErrEventDataNotRegistered }
go
func CreateEventData(eventType EventType) (EventData, error) { eventDataFactoriesMu.RLock() defer eventDataFactoriesMu.RUnlock() if factory, ok := eventDataFactories[eventType]; ok { return factory(), nil } return nil, ErrEventDataNotRegistered }
[ "func", "CreateEventData", "(", "eventType", "EventType", ")", "(", "EventData", ",", "error", ")", "{", "eventDataFactoriesMu", ".", "RLock", "(", ")", "\n", "defer", "eventDataFactoriesMu", ".", "RUnlock", "(", ")", "\n", "if", "factory", ",", "ok", ":=", ...
// CreateEventData creates an event data of a type using the factory registered // with RegisterEventData.
[ "CreateEventData", "creates", "an", "event", "data", "of", "a", "type", "using", "the", "factory", "registered", "with", "RegisterEventData", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/event.go#L176-L183
19,444
looplab/eventhorizon
examples/todomvc/internal/domain/aggregate.go
ApplyEvent
func (a *Aggregate) ApplyEvent(ctx context.Context, event eh.Event) error { switch event.EventType() { case Created: a.created = true case Deleted: a.created = false case ItemAdded: data, ok := event.Data().(*ItemAddedData) if !ok { return errors.New("invalid event data") } a.items = append(a.items, ...
go
func (a *Aggregate) ApplyEvent(ctx context.Context, event eh.Event) error { switch event.EventType() { case Created: a.created = true case Deleted: a.created = false case ItemAdded: data, ok := event.Data().(*ItemAddedData) if !ok { return errors.New("invalid event data") } a.items = append(a.items, ...
[ "func", "(", "a", "*", "Aggregate", ")", "ApplyEvent", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "error", "{", "switch", "event", ".", "EventType", "(", ")", "{", "case", "Created", ":", "a", ".", "created", "=", ...
// ApplyEvent implements the ApplyEvent method of the // eventhorizon.Aggregate interface.
[ "ApplyEvent", "implements", "the", "ApplyEvent", "method", "of", "the", "eventhorizon", ".", "Aggregate", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/todomvc/internal/domain/aggregate.go#L155-L206
19,445
looplab/eventhorizon
examples/todomvc/internal/domain/projector.go
Project
func (p *Projector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error) { model, ok := entity.(*TodoList) if !ok { return nil, errors.New("model is of incorrect type") } switch event.EventType() { case Created: // Set the ID when first created. model.ID = event.AggregateID() ...
go
func (p *Projector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error) { model, ok := entity.(*TodoList) if !ok { return nil, errors.New("model is of incorrect type") } switch event.EventType() { case Created: // Set the ID when first created. model.ID = event.AggregateID() ...
[ "func", "(", "p", "*", "Projector", ")", "Project", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ",", "entity", "eh", ".", "Entity", ")", "(", "eh", ".", "Entity", ",", "error", ")", "{", "model", ",", "ok", ":=", "ent...
// Project implements the Project method of the eventhorizon.Projector interface.
[ "Project", "implements", "the", "Project", "method", "of", "the", "eventhorizon", ".", "Projector", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/todomvc/internal/domain/projector.go#L36-L102
19,446
looplab/eventhorizon
eventhandler/waiter/eventhandler.go
NewEventHandler
func NewEventHandler() *EventHandler { h := EventHandler{ inbox: make(chan eh.Event, 1), register: make(chan *EventListener), unregister: make(chan *EventListener), } go h.run() return &h }
go
func NewEventHandler() *EventHandler { h := EventHandler{ inbox: make(chan eh.Event, 1), register: make(chan *EventListener), unregister: make(chan *EventListener), } go h.run() return &h }
[ "func", "NewEventHandler", "(", ")", "*", "EventHandler", "{", "h", ":=", "EventHandler", "{", "inbox", ":", "make", "(", "chan", "eh", ".", "Event", ",", "1", ")", ",", "register", ":", "make", "(", "chan", "*", "EventListener", ")", ",", "unregister"...
// NewEventHandler returns a new EventHandler.
[ "NewEventHandler", "returns", "a", "new", "EventHandler", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/waiter/eventhandler.go#L34-L42
19,447
looplab/eventhorizon
eventhandler/waiter/eventhandler.go
HandleEvent
func (h *EventHandler) HandleEvent(ctx context.Context, event eh.Event) error { h.inbox <- event return nil }
go
func (h *EventHandler) HandleEvent(ctx context.Context, event eh.Event) error { h.inbox <- event return nil }
[ "func", "(", "h", "*", "EventHandler", ")", "HandleEvent", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "error", "{", "h", ".", "inbox", "<-", "event", "\n", "return", "nil", "\n", "}" ]
// HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface. // It forwards events to the waiters so that they can match the events.
[ "HandleEvent", "implements", "the", "HandleEvent", "method", "of", "the", "eventhorizon", ".", "EventHandler", "interface", ".", "It", "forwards", "events", "to", "the", "waiters", "so", "that", "they", "can", "match", "the", "events", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/waiter/eventhandler.go#L51-L54
19,448
looplab/eventhorizon
eventhandler/waiter/eventhandler.go
Listen
func (h *EventHandler) Listen(match func(eh.Event) bool) *EventListener { l := &EventListener{ id: uuid.New(), inbox: make(chan eh.Event, 1), match: match, unregister: h.unregister, } // Register us to the in-flight listeners. h.register <- l return l }
go
func (h *EventHandler) Listen(match func(eh.Event) bool) *EventListener { l := &EventListener{ id: uuid.New(), inbox: make(chan eh.Event, 1), match: match, unregister: h.unregister, } // Register us to the in-flight listeners. h.register <- l return l }
[ "func", "(", "h", "*", "EventHandler", ")", "Listen", "(", "match", "func", "(", "eh", ".", "Event", ")", "bool", ")", "*", "EventListener", "{", "l", ":=", "&", "EventListener", "{", "id", ":", "uuid", ".", "New", "(", ")", ",", "inbox", ":", "m...
// Listen waits unil the match function returns true for an event, or the context // deadline expires. The match function can be used to filter or otherwise select // interesting events by analysing the event data.
[ "Listen", "waits", "unil", "the", "match", "function", "returns", "true", "for", "an", "event", "or", "the", "context", "deadline", "expires", ".", "The", "match", "function", "can", "be", "used", "to", "filter", "or", "otherwise", "select", "interesting", "...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/waiter/eventhandler.go#L59-L70
19,449
looplab/eventhorizon
eventhandler/waiter/eventhandler.go
Wait
func (l *EventListener) Wait(ctx context.Context) (eh.Event, error) { select { case event := <-l.inbox: return event, nil case <-ctx.Done(): return nil, ctx.Err() } }
go
func (l *EventListener) Wait(ctx context.Context) (eh.Event, error) { select { case event := <-l.inbox: return event, nil case <-ctx.Done(): return nil, ctx.Err() } }
[ "func", "(", "l", "*", "EventListener", ")", "Wait", "(", "ctx", "context", ".", "Context", ")", "(", "eh", ".", "Event", ",", "error", ")", "{", "select", "{", "case", "event", ":=", "<-", "l", ".", "inbox", ":", "return", "event", ",", "nil", "...
// Wait waits for the event to arrive or the context to be cancelled.
[ "Wait", "waits", "for", "the", "event", "to", "arrive", "or", "the", "context", "to", "be", "cancelled", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/waiter/eventhandler.go#L81-L88
19,450
looplab/eventhorizon
examples/guestlist/domain/setup.go
Setup
func Setup( eventStore eh.EventStore, eventBus eh.EventBus, commandBus *bus.CommandHandler, invitationRepo, guestListRepo eh.ReadWriteRepo, eventID uuid.UUID) { // Add a logger as an observer. eventBus.AddObserver(eh.MatchAny(), &Logger{}) // Create the aggregate repository. aggregateStore, err := events.New...
go
func Setup( eventStore eh.EventStore, eventBus eh.EventBus, commandBus *bus.CommandHandler, invitationRepo, guestListRepo eh.ReadWriteRepo, eventID uuid.UUID) { // Add a logger as an observer. eventBus.AddObserver(eh.MatchAny(), &Logger{}) // Create the aggregate repository. aggregateStore, err := events.New...
[ "func", "Setup", "(", "eventStore", "eh", ".", "EventStore", ",", "eventBus", "eh", ".", "EventBus", ",", "commandBus", "*", "bus", ".", "CommandHandler", ",", "invitationRepo", ",", "guestListRepo", "eh", ".", "ReadWriteRepo", ",", "eventID", "uuid", ".", "...
// Setup configures the domain.
[ "Setup", "configures", "the", "domain", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/setup.go#L30-L83
19,451
looplab/eventhorizon
commandhandler.go
HandleCommand
func (h CommandHandlerFunc) HandleCommand(ctx context.Context, cmd Command) error { return h(ctx, cmd) }
go
func (h CommandHandlerFunc) HandleCommand(ctx context.Context, cmd Command) error { return h(ctx, cmd) }
[ "func", "(", "h", "CommandHandlerFunc", ")", "HandleCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "Command", ")", "error", "{", "return", "h", "(", "ctx", ",", "cmd", ")", "\n", "}" ]
// HandleCommand implements the HandleCommand method of the CommandHandler.
[ "HandleCommand", "implements", "the", "HandleCommand", "method", "of", "the", "CommandHandler", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler.go#L30-L32
19,452
looplab/eventhorizon
commandhandler.go
UseCommandHandlerMiddleware
func UseCommandHandlerMiddleware(h CommandHandler, middleware ...CommandHandlerMiddleware) CommandHandler { // Apply in reverse order. for i := len(middleware) - 1; i >= 0; i-- { m := middleware[i] h = m(h) } return h }
go
func UseCommandHandlerMiddleware(h CommandHandler, middleware ...CommandHandlerMiddleware) CommandHandler { // Apply in reverse order. for i := len(middleware) - 1; i >= 0; i-- { m := middleware[i] h = m(h) } return h }
[ "func", "UseCommandHandlerMiddleware", "(", "h", "CommandHandler", ",", "middleware", "...", "CommandHandlerMiddleware", ")", "CommandHandler", "{", "// Apply in reverse order.", "for", "i", ":=", "len", "(", "middleware", ")", "-", "1", ";", "i", ">=", "0", ";", ...
// UseCommandHandlerMiddleware wraps a CommandHandler in one or more middleware.
[ "UseCommandHandlerMiddleware", "wraps", "a", "CommandHandler", "in", "one", "or", "more", "middleware", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler.go#L39-L46
19,453
looplab/eventhorizon
eventhandler/projector/eventhandler.go
Error
func (e Error) Error() string { errStr := e.Err.Error() if e.BaseErr != nil { errStr += ": " + e.BaseErr.Error() } return "projector: " + errStr + " (" + e.Namespace + ")" }
go
func (e Error) Error() string { errStr := e.Err.Error() if e.BaseErr != nil { errStr += ": " + e.BaseErr.Error() } return "projector: " + errStr + " (" + e.Namespace + ")" }
[ "func", "(", "e", "Error", ")", "Error", "(", ")", "string", "{", "errStr", ":=", "e", ".", "Err", ".", "Error", "(", ")", "\n", "if", "e", ".", "BaseErr", "!=", "nil", "{", "errStr", "+=", "\"", "\"", "+", "e", ".", "BaseErr", ".", "Error", ...
// Error implements the Error method of the errors.Error interface.
[ "Error", "implements", "the", "Error", "method", "of", "the", "errors", ".", "Error", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/projector/eventhandler.go#L57-L63
19,454
looplab/eventhorizon
eventhandler/projector/eventhandler.go
HandleEvent
func (h *EventHandler) HandleEvent(ctx context.Context, event eh.Event) error { // Get or create the model, trying to use a waiting find with a min version // if the underlying repo supports it. findCtx, cancel := eh.NewContextWithMinVersionWait(ctx, event.Version()-1) defer cancel() entity, err := h.repo.Find(fin...
go
func (h *EventHandler) HandleEvent(ctx context.Context, event eh.Event) error { // Get or create the model, trying to use a waiting find with a min version // if the underlying repo supports it. findCtx, cancel := eh.NewContextWithMinVersionWait(ctx, event.Version()-1) defer cancel() entity, err := h.repo.Find(fin...
[ "func", "(", "h", "*", "EventHandler", ")", "HandleEvent", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "error", "{", "// Get or create the model, trying to use a waiting find with a min version", "// if the underlying repo supports it.", ...
// HandleEvent implements the HandleEvent method of the eventhorizon.EventHandler interface. // It will try to find the correct version of the model, waiting for it if needed.
[ "HandleEvent", "implements", "the", "HandleEvent", "method", "of", "the", "eventhorizon", ".", "EventHandler", "interface", ".", "It", "will", "try", "to", "find", "the", "correct", "version", "of", "the", "model", "waiting", "for", "it", "if", "needed", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/projector/eventhandler.go#L83-L151
19,455
looplab/eventhorizon
eventbus/gcp/eventbus.go
NewEventBus
func NewEventBus(projectID, appID string, opts ...option.ClientOption) (*EventBus, error) { ctx := context.Background() client, err := pubsub.NewClient(ctx, projectID, opts...) if err != nil { return nil, err } // Get or create the topic. name := appID + "_events" topic := client.Topic(name) if ok, err := to...
go
func NewEventBus(projectID, appID string, opts ...option.ClientOption) (*EventBus, error) { ctx := context.Background() client, err := pubsub.NewClient(ctx, projectID, opts...) if err != nil { return nil, err } // Get or create the topic. name := appID + "_events" topic := client.Topic(name) if ok, err := to...
[ "func", "NewEventBus", "(", "projectID", ",", "appID", "string", ",", "opts", "...", "option", ".", "ClientOption", ")", "(", "*", "EventBus", ",", "error", ")", "{", "ctx", ":=", "context", ".", "Background", "(", ")", "\n", "client", ",", "err", ":="...
// NewEventBus creates an EventBus, with optional GCP connection settings.
[ "NewEventBus", "creates", "an", "EventBus", "with", "optional", "GCP", "connection", "settings", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/gcp/eventbus.go#L47-L72
19,456
looplab/eventhorizon
eventbus/gcp/eventbus.go
subscription
func (b *EventBus) subscription(m eh.EventMatcher, h eh.EventHandler, observer bool) *pubsub.Subscription { b.registeredMu.Lock() defer b.registeredMu.Unlock() if m == nil { panic("matcher can't be nil") } if h == nil { panic("handler can't be nil") } if _, ok := b.registered[h.HandlerType()]; ok { panic(...
go
func (b *EventBus) subscription(m eh.EventMatcher, h eh.EventHandler, observer bool) *pubsub.Subscription { b.registeredMu.Lock() defer b.registeredMu.Unlock() if m == nil { panic("matcher can't be nil") } if h == nil { panic("handler can't be nil") } if _, ok := b.registered[h.HandlerType()]; ok { panic(...
[ "func", "(", "b", "*", "EventBus", ")", "subscription", "(", "m", "eh", ".", "EventMatcher", ",", "h", "eh", ".", "EventHandler", ",", "observer", "bool", ")", "*", "pubsub", ".", "Subscription", "{", "b", ".", "registeredMu", ".", "Lock", "(", ")", ...
// Checks the matcher and handler and gets the event subscription.
[ "Checks", "the", "matcher", "and", "handler", "and", "gets", "the", "event", "subscription", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/gcp/eventbus.go#L131-L170
19,457
looplab/eventhorizon
eventbus/gcp/eventbus.go
AggregateID
func (e event) AggregateID() uuid.UUID { id, err := uuid.Parse(e.evt.AggregateID) if err != nil { return uuid.Nil } return id }
go
func (e event) AggregateID() uuid.UUID { id, err := uuid.Parse(e.evt.AggregateID) if err != nil { return uuid.Nil } return id }
[ "func", "(", "e", "event", ")", "AggregateID", "(", ")", "uuid", ".", "UUID", "{", "id", ",", "err", ":=", "uuid", ".", "Parse", "(", "e", ".", "evt", ".", "AggregateID", ")", "\n", "if", "err", "!=", "nil", "{", "return", "uuid", ".", "Nil", "...
// AggrgateID implements the AggrgateID method of the eventhorizon.Event interface.
[ "AggrgateID", "implements", "the", "AggrgateID", "method", "of", "the", "eventhorizon", ".", "Event", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventbus/gcp/eventbus.go#L281-L287
19,458
looplab/eventhorizon
eventhandler.go
HandleEvent
func (h EventHandlerFunc) HandleEvent(ctx context.Context, e Event) error { return h(ctx, e) }
go
func (h EventHandlerFunc) HandleEvent(ctx context.Context, e Event) error { return h(ctx, e) }
[ "func", "(", "h", "EventHandlerFunc", ")", "HandleEvent", "(", "ctx", "context", ".", "Context", ",", "e", "Event", ")", "error", "{", "return", "h", "(", "ctx", ",", "e", ")", "\n", "}" ]
// HandleEvent implements the HandleEvent method of the EventHandler.
[ "HandleEvent", "implements", "the", "HandleEvent", "method", "of", "the", "EventHandler", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler.go#L40-L42
19,459
looplab/eventhorizon
eventhandler.go
UseEventHandlerMiddleware
func UseEventHandlerMiddleware(h EventHandler, middleware ...EventHandlerMiddleware) EventHandler { // Apply in reverse order. for i := len(middleware) - 1; i >= 0; i-- { m := middleware[i] h = m(h) } return h }
go
func UseEventHandlerMiddleware(h EventHandler, middleware ...EventHandlerMiddleware) EventHandler { // Apply in reverse order. for i := len(middleware) - 1; i >= 0; i-- { m := middleware[i] h = m(h) } return h }
[ "func", "UseEventHandlerMiddleware", "(", "h", "EventHandler", ",", "middleware", "...", "EventHandlerMiddleware", ")", "EventHandler", "{", "// Apply in reverse order.", "for", "i", ":=", "len", "(", "middleware", ")", "-", "1", ";", "i", ">=", "0", ";", "i", ...
// UseEventHandlerMiddleware wraps a EventHandler in one or more middleware.
[ "UseEventHandlerMiddleware", "wraps", "a", "EventHandler", "in", "one", "or", "more", "middleware", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler.go#L55-L62
19,460
looplab/eventhorizon
eventstore/mongodb/eventstore.go
NewEventStoreWithSession
func NewEventStoreWithSession(session *mgo.Session, dbPrefix string) (*EventStore, error) { if session == nil { return nil, ErrNoDBSession } s := &EventStore{ session: session, dbPrefix: dbPrefix, } return s, nil }
go
func NewEventStoreWithSession(session *mgo.Session, dbPrefix string) (*EventStore, error) { if session == nil { return nil, ErrNoDBSession } s := &EventStore{ session: session, dbPrefix: dbPrefix, } return s, nil }
[ "func", "NewEventStoreWithSession", "(", "session", "*", "mgo", ".", "Session", ",", "dbPrefix", "string", ")", "(", "*", "EventStore", ",", "error", ")", "{", "if", "session", "==", "nil", "{", "return", "nil", ",", "ErrNoDBSession", "\n", "}", "\n\n", ...
// NewEventStoreWithSession creates a new EventStore with a session.
[ "NewEventStoreWithSession", "creates", "a", "new", "EventStore", "with", "a", "session", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/mongodb/eventstore.go#L71-L82
19,461
looplab/eventhorizon
eventstore/mongodb/eventstore.go
Clear
func (s *EventStore) Clear(ctx context.Context) error { if err := s.session.DB(s.dbName(ctx)).C("events").DropCollection(); err != nil { return eh.EventStoreError{ BaseErr: err, Err: ErrCouldNotClearDB, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
go
func (s *EventStore) Clear(ctx context.Context) error { if err := s.session.DB(s.dbName(ctx)).C("events").DropCollection(); err != nil { return eh.EventStoreError{ BaseErr: err, Err: ErrCouldNotClearDB, Namespace: eh.NamespaceFromContext(ctx), } } return nil }
[ "func", "(", "s", "*", "EventStore", ")", "Clear", "(", "ctx", "context", ".", "Context", ")", "error", "{", "if", "err", ":=", "s", ".", "session", ".", "DB", "(", "s", ".", "dbName", "(", "ctx", ")", ")", ".", "C", "(", "\"", "\"", ")", "."...
// Clear clears the event storage.
[ "Clear", "clears", "the", "event", "storage", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/mongodb/eventstore.go#L281-L290
19,462
looplab/eventhorizon
eventstore/mongodb/eventstore.go
String
func (e event) String() string { return fmt.Sprintf("%s@%d", e.dbEvent.EventType, e.dbEvent.Version) }
go
func (e event) String() string { return fmt.Sprintf("%s@%d", e.dbEvent.EventType, e.dbEvent.Version) }
[ "func", "(", "e", "event", ")", "String", "(", ")", "string", "{", "return", "fmt", ".", "Sprintf", "(", "\"", "\"", ",", "e", ".", "dbEvent", ".", "EventType", ",", "e", ".", "dbEvent", ".", "Version", ")", "\n", "}" ]
// String implements the String method of the eventhorizon.Event interface.
[ "String", "implements", "the", "String", "method", "of", "the", "eventhorizon", ".", "Event", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/mongodb/eventstore.go#L392-L394
19,463
looplab/eventhorizon
examples/guestlist/domain/projectors.go
Project
func (p *InvitationProjector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error) { i, ok := entity.(*Invitation) if !ok { return nil, errors.New("model is of incorrect type") } // Apply the changes for the event. switch event.EventType() { case InviteCreatedEvent: data, ok := e...
go
func (p *InvitationProjector) Project(ctx context.Context, event eh.Event, entity eh.Entity) (eh.Entity, error) { i, ok := entity.(*Invitation) if !ok { return nil, errors.New("model is of incorrect type") } // Apply the changes for the event. switch event.EventType() { case InviteCreatedEvent: data, ok := e...
[ "func", "(", "p", "*", "InvitationProjector", ")", "Project", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ",", "entity", "eh", ".", "Entity", ")", "(", "eh", ".", "Entity", ",", "error", ")", "{", "i", ",", "ok", ":=", ...
// Project implements the Project method of the Projector interface.
[ "Project", "implements", "the", "Project", "method", "of", "the", "Projector", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/projectors.go#L65-L100
19,464
looplab/eventhorizon
examples/guestlist/domain/projectors.go
NewGuestListProjector
func NewGuestListProjector(repo eh.ReadWriteRepo, eventID uuid.UUID) *GuestListProjector { p := &GuestListProjector{ repo: repo, eventID: eventID, } return p }
go
func NewGuestListProjector(repo eh.ReadWriteRepo, eventID uuid.UUID) *GuestListProjector { p := &GuestListProjector{ repo: repo, eventID: eventID, } return p }
[ "func", "NewGuestListProjector", "(", "repo", "eh", ".", "ReadWriteRepo", ",", "eventID", "uuid", ".", "UUID", ")", "*", "GuestListProjector", "{", "p", ":=", "&", "GuestListProjector", "{", "repo", ":", "repo", ",", "eventID", ":", "eventID", ",", "}", "\...
// NewGuestListProjector creates a new GuestListProjector.
[ "NewGuestListProjector", "creates", "a", "new", "GuestListProjector", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/projectors.go#L128-L134
19,465
looplab/eventhorizon
command.go
UnregisterCommand
func UnregisterCommand(commandType CommandType) { if commandType == CommandType("") { panic("eventhorizon: attempt to unregister empty command type") } commandsMu.Lock() defer commandsMu.Unlock() if _, ok := commands[commandType]; !ok { panic(fmt.Sprintf("eventhorizon: unregister of non-registered type %q", c...
go
func UnregisterCommand(commandType CommandType) { if commandType == CommandType("") { panic("eventhorizon: attempt to unregister empty command type") } commandsMu.Lock() defer commandsMu.Unlock() if _, ok := commands[commandType]; !ok { panic(fmt.Sprintf("eventhorizon: unregister of non-registered type %q", c...
[ "func", "UnregisterCommand", "(", "commandType", "CommandType", ")", "{", "if", "commandType", "==", "CommandType", "(", "\"", "\"", ")", "{", "panic", "(", "\"", "\"", ")", "\n", "}", "\n\n", "commandsMu", ".", "Lock", "(", ")", "\n", "defer", "commands...
// UnregisterCommand removes the registration of the command factory for // a type. This is mainly useful in mainenance situations where the command type // needs to be switched at runtime.
[ "UnregisterCommand", "removes", "the", "registration", "of", "the", "command", "factory", "for", "a", "type", ".", "This", "is", "mainly", "useful", "in", "mainenance", "situations", "where", "the", "command", "type", "needs", "to", "be", "switched", "at", "ru...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/command.go#L87-L98
19,466
looplab/eventhorizon
command.go
CreateCommand
func CreateCommand(commandType CommandType) (Command, error) { commandsMu.RLock() defer commandsMu.RUnlock() if factory, ok := commands[commandType]; ok { return factory(), nil } return nil, ErrCommandNotRegistered }
go
func CreateCommand(commandType CommandType) (Command, error) { commandsMu.RLock() defer commandsMu.RUnlock() if factory, ok := commands[commandType]; ok { return factory(), nil } return nil, ErrCommandNotRegistered }
[ "func", "CreateCommand", "(", "commandType", "CommandType", ")", "(", "Command", ",", "error", ")", "{", "commandsMu", ".", "RLock", "(", ")", "\n", "defer", "commandsMu", ".", "RUnlock", "(", ")", "\n", "if", "factory", ",", "ok", ":=", "commands", "[",...
// CreateCommand creates an command of a type with an ID using the factory // registered with RegisterCommand.
[ "CreateCommand", "creates", "an", "command", "of", "a", "type", "with", "an", "ID", "using", "the", "factory", "registered", "with", "RegisterCommand", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/command.go#L102-L109
19,467
looplab/eventhorizon
command.go
CheckCommand
func CheckCommand(cmd Command) error { rv := reflect.Indirect(reflect.ValueOf(cmd)) rt := rv.Type() for i := 0; i < rt.NumField(); i++ { field := rt.Field(i) if field.PkgPath != "" { continue // Skip private field. } tag := field.Tag.Get("eh") if tag == "optional" { continue // Optional field. } ...
go
func CheckCommand(cmd Command) error { rv := reflect.Indirect(reflect.ValueOf(cmd)) rt := rv.Type() for i := 0; i < rt.NumField(); i++ { field := rt.Field(i) if field.PkgPath != "" { continue // Skip private field. } tag := field.Tag.Get("eh") if tag == "optional" { continue // Optional field. } ...
[ "func", "CheckCommand", "(", "cmd", "Command", ")", "error", "{", "rv", ":=", "reflect", ".", "Indirect", "(", "reflect", ".", "ValueOf", "(", "cmd", ")", ")", "\n", "rt", ":=", "rv", ".", "Type", "(", ")", "\n\n", "for", "i", ":=", "0", ";", "i"...
// CheckCommand checks a command for errors.
[ "CheckCommand", "checks", "a", "command", "for", "errors", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/command.go#L121-L141
19,468
looplab/eventhorizon
eventhandler/cron/eventhandler.go
ScheduleEvent
func (h *EventHandler) ScheduleEvent(ctx context.Context, cronLine string, eventFunc func(time.Time) eh.Event) error { expr, err := cronexpr.Parse(cronLine) if err != nil { return err } go func() { for { nextTime := expr.Next(time.Now()) select { case <-time.After(nextTime.Sub(time.Now())): h.even...
go
func (h *EventHandler) ScheduleEvent(ctx context.Context, cronLine string, eventFunc func(time.Time) eh.Event) error { expr, err := cronexpr.Parse(cronLine) if err != nil { return err } go func() { for { nextTime := expr.Next(time.Now()) select { case <-time.After(nextTime.Sub(time.Now())): h.even...
[ "func", "(", "h", "*", "EventHandler", ")", "ScheduleEvent", "(", "ctx", "context", ".", "Context", ",", "cronLine", "string", ",", "eventFunc", "func", "(", "time", ".", "Time", ")", "eh", ".", "Event", ")", "error", "{", "expr", ",", "err", ":=", "...
// ScheduleEvent schedules an event to be sent on regular intervals, using // a line in the crontab format to setup the timing. The eventFunc should create // the event to send given the triggered time as input. Cancelling the context // will stop the triggering of more events.
[ "ScheduleEvent", "schedules", "an", "event", "to", "be", "sent", "on", "regular", "intervals", "using", "a", "line", "in", "the", "crontab", "format", "to", "setup", "the", "timing", ".", "The", "eventFunc", "should", "create", "the", "event", "to", "send", ...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventhandler/cron/eventhandler.go#L54-L73
19,469
looplab/eventhorizon
matcher.go
MatchEvent
func MatchEvent(t EventType) EventMatcher { return func(e Event) bool { return e != nil && e.EventType() == t } }
go
func MatchEvent(t EventType) EventMatcher { return func(e Event) bool { return e != nil && e.EventType() == t } }
[ "func", "MatchEvent", "(", "t", "EventType", ")", "EventMatcher", "{", "return", "func", "(", "e", "Event", ")", "bool", "{", "return", "e", "!=", "nil", "&&", "e", ".", "EventType", "(", ")", "==", "t", "\n", "}", "\n", "}" ]
// MatchEvent matches a specific event type, nil events never match.
[ "MatchEvent", "matches", "a", "specific", "event", "type", "nil", "events", "never", "match", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/matcher.go#L28-L32
19,470
looplab/eventhorizon
matcher.go
MatchAggregate
func MatchAggregate(t AggregateType) EventMatcher { return func(e Event) bool { return e != nil && e.AggregateType() == t } }
go
func MatchAggregate(t AggregateType) EventMatcher { return func(e Event) bool { return e != nil && e.AggregateType() == t } }
[ "func", "MatchAggregate", "(", "t", "AggregateType", ")", "EventMatcher", "{", "return", "func", "(", "e", "Event", ")", "bool", "{", "return", "e", "!=", "nil", "&&", "e", ".", "AggregateType", "(", ")", "==", "t", "\n", "}", "\n", "}" ]
// MatchAggregate matches a specific aggregate type, nil events never match.
[ "MatchAggregate", "matches", "a", "specific", "aggregate", "type", "nil", "events", "never", "match", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/matcher.go#L35-L39
19,471
looplab/eventhorizon
matcher.go
MatchAnyOf
func MatchAnyOf(matchers ...EventMatcher) EventMatcher { return func(e Event) bool { for _, m := range matchers { if m(e) { return true } } return false } }
go
func MatchAnyOf(matchers ...EventMatcher) EventMatcher { return func(e Event) bool { for _, m := range matchers { if m(e) { return true } } return false } }
[ "func", "MatchAnyOf", "(", "matchers", "...", "EventMatcher", ")", "EventMatcher", "{", "return", "func", "(", "e", "Event", ")", "bool", "{", "for", "_", ",", "m", ":=", "range", "matchers", "{", "if", "m", "(", "e", ")", "{", "return", "true", "\n"...
// MatchAnyOf matches if any of several matchers matches.
[ "MatchAnyOf", "matches", "if", "any", "of", "several", "matchers", "matches", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/matcher.go#L42-L51
19,472
looplab/eventhorizon
matcher.go
MatchAnyEventOf
func MatchAnyEventOf(types ...EventType) EventMatcher { return func(e Event) bool { for _, t := range types { if MatchEvent(t)(e) { return true } } return false } }
go
func MatchAnyEventOf(types ...EventType) EventMatcher { return func(e Event) bool { for _, t := range types { if MatchEvent(t)(e) { return true } } return false } }
[ "func", "MatchAnyEventOf", "(", "types", "...", "EventType", ")", "EventMatcher", "{", "return", "func", "(", "e", "Event", ")", "bool", "{", "for", "_", ",", "t", ":=", "range", "types", "{", "if", "MatchEvent", "(", "t", ")", "(", "e", ")", "{", ...
// MatchAnyEventOf matches if any of several matchers matches.
[ "MatchAnyEventOf", "matches", "if", "any", "of", "several", "matchers", "matches", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/matcher.go#L54-L63
19,473
looplab/eventhorizon
commandhandler/bus/commandhandler.go
HandleCommand
func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eh.Command) error { h.handlersMu.RLock() defer h.handlersMu.RUnlock() if handler, ok := h.handlers[cmd.CommandType()]; ok { return handler.HandleCommand(ctx, cmd) } return ErrHandlerNotFound }
go
func (h *CommandHandler) HandleCommand(ctx context.Context, cmd eh.Command) error { h.handlersMu.RLock() defer h.handlersMu.RUnlock() if handler, ok := h.handlers[cmd.CommandType()]; ok { return handler.HandleCommand(ctx, cmd) } return ErrHandlerNotFound }
[ "func", "(", "h", "*", "CommandHandler", ")", "HandleCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "eh", ".", "Command", ")", "error", "{", "h", ".", "handlersMu", ".", "RLock", "(", ")", "\n", "defer", "h", ".", "handlersMu", ".", "RU...
// HandleCommand handles a command with a handler capable of handling it.
[ "HandleCommand", "handles", "a", "command", "with", "a", "handler", "capable", "of", "handling", "it", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler/bus/commandhandler.go#L46-L55
19,474
looplab/eventhorizon
commandhandler/bus/commandhandler.go
SetHandler
func (h *CommandHandler) SetHandler(handler eh.CommandHandler, cmdType eh.CommandType) error { h.handlersMu.Lock() defer h.handlersMu.Unlock() if _, ok := h.handlers[cmdType]; ok { return ErrHandlerAlreadySet } h.handlers[cmdType] = handler return nil }
go
func (h *CommandHandler) SetHandler(handler eh.CommandHandler, cmdType eh.CommandType) error { h.handlersMu.Lock() defer h.handlersMu.Unlock() if _, ok := h.handlers[cmdType]; ok { return ErrHandlerAlreadySet } h.handlers[cmdType] = handler return nil }
[ "func", "(", "h", "*", "CommandHandler", ")", "SetHandler", "(", "handler", "eh", ".", "CommandHandler", ",", "cmdType", "eh", ".", "CommandType", ")", "error", "{", "h", ".", "handlersMu", ".", "Lock", "(", ")", "\n", "defer", "h", ".", "handlersMu", ...
// SetHandler adds a handler for a specific command.
[ "SetHandler", "adds", "a", "handler", "for", "a", "specific", "command", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/commandhandler/bus/commandhandler.go#L58-L68
19,475
looplab/eventhorizon
eventstore/memory/eventstore.go
NewEventStore
func NewEventStore() *EventStore { s := &EventStore{ db: map[string]map[uuid.UUID]aggregateRecord{}, } return s }
go
func NewEventStore() *EventStore { s := &EventStore{ db: map[string]map[uuid.UUID]aggregateRecord{}, } return s }
[ "func", "NewEventStore", "(", ")", "*", "EventStore", "{", "s", ":=", "&", "EventStore", "{", "db", ":", "map", "[", "string", "]", "map", "[", "uuid", ".", "UUID", "]", "aggregateRecord", "{", "}", ",", "}", "\n", "return", "s", "\n", "}" ]
// NewEventStore creates a new EventStore using memory as storage.
[ "NewEventStore", "creates", "a", "new", "EventStore", "using", "memory", "as", "storage", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/memory/eventstore.go#L39-L44
19,476
looplab/eventhorizon
eventstore/trace/eventstore.go
StartTracing
func (s *EventStore) StartTracing() { s.traceMu.Lock() defer s.traceMu.Unlock() s.tracing = true }
go
func (s *EventStore) StartTracing() { s.traceMu.Lock() defer s.traceMu.Unlock() s.tracing = true }
[ "func", "(", "s", "*", "EventStore", ")", "StartTracing", "(", ")", "{", "s", ".", "traceMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "traceMu", ".", "Unlock", "(", ")", "\n\n", "s", ".", "tracing", "=", "true", "\n", "}" ]
// StartTracing starts the tracing of events.
[ "StartTracing", "starts", "the", "tracing", "of", "events", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/trace/eventstore.go#L61-L66
19,477
looplab/eventhorizon
eventstore/trace/eventstore.go
StopTracing
func (s *EventStore) StopTracing() { s.traceMu.Lock() defer s.traceMu.Unlock() s.tracing = false }
go
func (s *EventStore) StopTracing() { s.traceMu.Lock() defer s.traceMu.Unlock() s.tracing = false }
[ "func", "(", "s", "*", "EventStore", ")", "StopTracing", "(", ")", "{", "s", ".", "traceMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "traceMu", ".", "Unlock", "(", ")", "\n\n", "s", ".", "tracing", "=", "false", "\n", "}" ]
// StopTracing stops the tracing of events.
[ "StopTracing", "stops", "the", "tracing", "of", "events", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/trace/eventstore.go#L69-L74
19,478
looplab/eventhorizon
eventstore/trace/eventstore.go
GetTrace
func (s *EventStore) GetTrace() []eh.Event { s.traceMu.RLock() defer s.traceMu.RUnlock() return s.trace }
go
func (s *EventStore) GetTrace() []eh.Event { s.traceMu.RLock() defer s.traceMu.RUnlock() return s.trace }
[ "func", "(", "s", "*", "EventStore", ")", "GetTrace", "(", ")", "[", "]", "eh", ".", "Event", "{", "s", ".", "traceMu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "traceMu", ".", "RUnlock", "(", ")", "\n\n", "return", "s", ".", "trace", "...
// GetTrace returns the events that happened during the tracing.
[ "GetTrace", "returns", "the", "events", "that", "happened", "during", "the", "tracing", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/trace/eventstore.go#L77-L82
19,479
looplab/eventhorizon
eventstore/trace/eventstore.go
ResetTrace
func (s *EventStore) ResetTrace() { s.traceMu.Lock() defer s.traceMu.Unlock() s.trace = make([]eh.Event, 0) }
go
func (s *EventStore) ResetTrace() { s.traceMu.Lock() defer s.traceMu.Unlock() s.trace = make([]eh.Event, 0) }
[ "func", "(", "s", "*", "EventStore", ")", "ResetTrace", "(", ")", "{", "s", ".", "traceMu", ".", "Lock", "(", ")", "\n", "defer", "s", ".", "traceMu", ".", "Unlock", "(", ")", "\n\n", "s", ".", "trace", "=", "make", "(", "[", "]", "eh", ".", ...
// ResetTrace resets the trace.
[ "ResetTrace", "resets", "the", "trace", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/eventstore/trace/eventstore.go#L85-L90
19,480
looplab/eventhorizon
examples/guestlist/domain/aggregate.go
NewInvitationAggregate
func NewInvitationAggregate(id uuid.UUID) *InvitationAggregate { return &InvitationAggregate{ AggregateBase: events.NewAggregateBase(InvitationAggregateType, id), } }
go
func NewInvitationAggregate(id uuid.UUID) *InvitationAggregate { return &InvitationAggregate{ AggregateBase: events.NewAggregateBase(InvitationAggregateType, id), } }
[ "func", "NewInvitationAggregate", "(", "id", "uuid", ".", "UUID", ")", "*", "InvitationAggregate", "{", "return", "&", "InvitationAggregate", "{", "AggregateBase", ":", "events", ".", "NewAggregateBase", "(", "InvitationAggregateType", ",", "id", ")", ",", "}", ...
// NewInvitationAggregate creates a new InvitationAggregate with an ID.
[ "NewInvitationAggregate", "creates", "a", "new", "InvitationAggregate", "with", "an", "ID", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/aggregate.go#L58-L62
19,481
looplab/eventhorizon
examples/guestlist/domain/aggregate.go
HandleCommand
func (a *InvitationAggregate) HandleCommand(ctx context.Context, cmd eh.Command) error { switch cmd := cmd.(type) { case *CreateInvite: a.StoreEvent(InviteCreatedEvent, &InviteCreatedData{ cmd.Name, cmd.Age, }, time.Now(), ) return nil case *AcceptInvite: if a.name == "" { return fmt.Err...
go
func (a *InvitationAggregate) HandleCommand(ctx context.Context, cmd eh.Command) error { switch cmd := cmd.(type) { case *CreateInvite: a.StoreEvent(InviteCreatedEvent, &InviteCreatedData{ cmd.Name, cmd.Age, }, time.Now(), ) return nil case *AcceptInvite: if a.name == "" { return fmt.Err...
[ "func", "(", "a", "*", "InvitationAggregate", ")", "HandleCommand", "(", "ctx", "context", ".", "Context", ",", "cmd", "eh", ".", "Command", ")", "error", "{", "switch", "cmd", ":=", "cmd", ".", "(", "type", ")", "{", "case", "*", "CreateInvite", ":", ...
// HandleCommand implements the HandleCommand method of the Aggregate interface.
[ "HandleCommand", "implements", "the", "HandleCommand", "method", "of", "the", "Aggregate", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/aggregate.go#L65-L134
19,482
looplab/eventhorizon
examples/guestlist/domain/aggregate.go
ApplyEvent
func (a *InvitationAggregate) ApplyEvent(ctx context.Context, event eh.Event) error { switch event.EventType() { case InviteCreatedEvent: if data, ok := event.Data().(*InviteCreatedData); ok { a.name = data.Name a.age = data.Age } else { log.Println("invalid event data type:", event.Data()) } case Inv...
go
func (a *InvitationAggregate) ApplyEvent(ctx context.Context, event eh.Event) error { switch event.EventType() { case InviteCreatedEvent: if data, ok := event.Data().(*InviteCreatedData); ok { a.name = data.Name a.age = data.Age } else { log.Println("invalid event data type:", event.Data()) } case Inv...
[ "func", "(", "a", "*", "InvitationAggregate", ")", "ApplyEvent", "(", "ctx", "context", ".", "Context", ",", "event", "eh", ".", "Event", ")", "error", "{", "switch", "event", ".", "EventType", "(", ")", "{", "case", "InviteCreatedEvent", ":", "if", "dat...
// ApplyEvent implements the ApplyEvent method of the Aggregate interface.
[ "ApplyEvent", "implements", "the", "ApplyEvent", "method", "of", "the", "Aggregate", "interface", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/examples/guestlist/domain/aggregate.go#L137-L156
19,483
looplab/eventhorizon
aggregate.go
CreateAggregate
func CreateAggregate(aggregateType AggregateType, id uuid.UUID) (Aggregate, error) { aggregatesMu.RLock() defer aggregatesMu.RUnlock() if factory, ok := aggregates[aggregateType]; ok { return factory(id), nil } return nil, ErrAggregateNotRegistered }
go
func CreateAggregate(aggregateType AggregateType, id uuid.UUID) (Aggregate, error) { aggregatesMu.RLock() defer aggregatesMu.RUnlock() if factory, ok := aggregates[aggregateType]; ok { return factory(id), nil } return nil, ErrAggregateNotRegistered }
[ "func", "CreateAggregate", "(", "aggregateType", "AggregateType", ",", "id", "uuid", ".", "UUID", ")", "(", "Aggregate", ",", "error", ")", "{", "aggregatesMu", ".", "RLock", "(", ")", "\n", "defer", "aggregatesMu", ".", "RUnlock", "(", ")", "\n", "if", ...
// CreateAggregate creates an aggregate of a type with an ID using the factory // registered with RegisterAggregate.
[ "CreateAggregate", "creates", "an", "aggregate", "of", "a", "type", "with", "an", "ID", "using", "the", "factory", "registered", "with", "RegisterAggregate", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/aggregate.go#L94-L101
19,484
optiopay/klar
main.go
filterWhitelist
func filterWhitelist(whitelist *vulnerabilitiesWhitelist, vs []*clair.Vulnerability, imageName string) []*clair.Vulnerability { generalWhitelist := whitelist.General imageWhitelist := whitelist.Images filteredVs := make([]*clair.Vulnerability, 0, len(vs)) for _, v := range vs { if _, exists := generalWhitelist[...
go
func filterWhitelist(whitelist *vulnerabilitiesWhitelist, vs []*clair.Vulnerability, imageName string) []*clair.Vulnerability { generalWhitelist := whitelist.General imageWhitelist := whitelist.Images filteredVs := make([]*clair.Vulnerability, 0, len(vs)) for _, v := range vs { if _, exists := generalWhitelist[...
[ "func", "filterWhitelist", "(", "whitelist", "*", "vulnerabilitiesWhitelist", ",", "vs", "[", "]", "*", "clair", ".", "Vulnerability", ",", "imageName", "string", ")", "[", "]", "*", "clair", ".", "Vulnerability", "{", "generalWhitelist", ":=", "whitelist", "....
//Filter out whitelisted vulnerabilites
[ "Filter", "out", "whitelisted", "vulnerabilites" ]
99ad65f257636385fed0c6ef0997dc020687ee71
https://github.com/optiopay/klar/blob/99ad65f257636385fed0c6ef0997dc020687ee71/main.go#L133-L149
19,485
optiopay/klar
docker/docker.go
Pull
func (i *Image) Pull() error { resp, err := i.pullReq() if err != nil { return err } defer resp.Body.Close() if resp.StatusCode == http.StatusUnauthorized { i.Token, err = i.requestToken(resp) io.Copy(ioutil.Discard, resp.Body) if err != nil { return err } // try again resp, err = i.pullReq() if...
go
func (i *Image) Pull() error { resp, err := i.pullReq() if err != nil { return err } defer resp.Body.Close() if resp.StatusCode == http.StatusUnauthorized { i.Token, err = i.requestToken(resp) io.Copy(ioutil.Discard, resp.Body) if err != nil { return err } // try again resp, err = i.pullReq() if...
[ "func", "(", "i", "*", "Image", ")", "Pull", "(", ")", "error", "{", "resp", ",", "err", ":=", "i", ".", "pullReq", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n", "defer", "resp", ".", "Body", ".", "Close", "...
// Pull retrieves information about layers from docker registry. // It gets docker registry token if needed.
[ "Pull", "retrieves", "information", "about", "layers", "from", "docker", "registry", ".", "It", "gets", "docker", "registry", "token", "if", "needed", "." ]
99ad65f257636385fed0c6ef0997dc020687ee71
https://github.com/optiopay/klar/blob/99ad65f257636385fed0c6ef0997dc020687ee71/docker/docker.go#L235-L267
19,486
optiopay/klar
klar.go
parseWhitelistFile
func parseWhitelistFile(whitelistFile string) (*vulnerabilitiesWhitelist, error) { whitelistYAML := vulnerabilitiesWhitelistYAML{} whitelist := vulnerabilitiesWhitelist{} //read the whitelist file whitelistBytes, err := ioutil.ReadFile(whitelistFile) if err != nil { return nil, fmt.Errorf("could not read file %...
go
func parseWhitelistFile(whitelistFile string) (*vulnerabilitiesWhitelist, error) { whitelistYAML := vulnerabilitiesWhitelistYAML{} whitelist := vulnerabilitiesWhitelist{} //read the whitelist file whitelistBytes, err := ioutil.ReadFile(whitelistFile) if err != nil { return nil, fmt.Errorf("could not read file %...
[ "func", "parseWhitelistFile", "(", "whitelistFile", "string", ")", "(", "*", "vulnerabilitiesWhitelist", ",", "error", ")", "{", "whitelistYAML", ":=", "vulnerabilitiesWhitelistYAML", "{", "}", "\n", "whitelist", ":=", "vulnerabilitiesWhitelist", "{", "}", "\n\n", "...
//Parse the whitelist file
[ "Parse", "the", "whitelist", "file" ]
99ad65f257636385fed0c6ef0997dc020687ee71
https://github.com/optiopay/klar/blob/99ad65f257636385fed0c6ef0997dc020687ee71/klar.go#L187-L217
19,487
optiopay/klar
clair/clair.go
NewClair
func NewClair(url string, version int, timeout time.Duration) Clair { api, err := newAPI(url, version, timeout) if err != nil { panic(fmt.Sprintf("cant't create API client version %d %s: %s", version, url, err)) } return Clair{url, api} }
go
func NewClair(url string, version int, timeout time.Duration) Clair { api, err := newAPI(url, version, timeout) if err != nil { panic(fmt.Sprintf("cant't create API client version %d %s: %s", version, url, err)) } return Clair{url, api} }
[ "func", "NewClair", "(", "url", "string", ",", "version", "int", ",", "timeout", "time", ".", "Duration", ")", "Clair", "{", "api", ",", "err", ":=", "newAPI", "(", "url", ",", "version", ",", "timeout", ")", "\n", "if", "err", "!=", "nil", "{", "p...
// NewClair construct Clair entity using potentially incomplete server URL // If protocol is missing HTTP will be used. If port is missing 6060 will be used
[ "NewClair", "construct", "Clair", "entity", "using", "potentially", "incomplete", "server", "URL", "If", "protocol", "is", "missing", "HTTP", "will", "be", "used", ".", "If", "port", "is", "missing", "6060", "will", "be", "used" ]
99ad65f257636385fed0c6ef0997dc020687ee71
https://github.com/optiopay/klar/blob/99ad65f257636385fed0c6ef0997dc020687ee71/clair/clair.go#L75-L82
19,488
optiopay/klar
clair/clair.go
Analyse
func (c *Clair) Analyse(image *docker.Image) ([]*Vulnerability, error) { // Filter the empty layers in image image.FsLayers = filterEmptyLayers(image.FsLayers) layerLength := len(image.FsLayers) if layerLength == 0 { fmt.Fprintf(os.Stderr, "no need to analyse image %s/%s:%s as there is no non-emtpy layer\n", i...
go
func (c *Clair) Analyse(image *docker.Image) ([]*Vulnerability, error) { // Filter the empty layers in image image.FsLayers = filterEmptyLayers(image.FsLayers) layerLength := len(image.FsLayers) if layerLength == 0 { fmt.Fprintf(os.Stderr, "no need to analyse image %s/%s:%s as there is no non-emtpy layer\n", i...
[ "func", "(", "c", "*", "Clair", ")", "Analyse", "(", "image", "*", "docker", ".", "Image", ")", "(", "[", "]", "*", "Vulnerability", ",", "error", ")", "{", "// Filter the empty layers in image", "image", ".", "FsLayers", "=", "filterEmptyLayers", "(", "im...
// Analyse sent each layer from Docker image to Clair and returns // a list of found vulnerabilities
[ "Analyse", "sent", "each", "layer", "from", "Docker", "image", "to", "Clair", "and", "returns", "a", "list", "of", "found", "vulnerabilities" ]
99ad65f257636385fed0c6ef0997dc020687ee71
https://github.com/optiopay/klar/blob/99ad65f257636385fed0c6ef0997dc020687ee71/clair/clair.go#L110-L129
19,489
StackExchange/wmi
wmi.go
QueryNamespace
func QueryNamespace(query string, dst interface{}, namespace string) error { return Query(query, dst, nil, namespace) }
go
func QueryNamespace(query string, dst interface{}, namespace string) error { return Query(query, dst, nil, namespace) }
[ "func", "QueryNamespace", "(", "query", "string", ",", "dst", "interface", "{", "}", ",", "namespace", "string", ")", "error", "{", "return", "Query", "(", "query", ",", "dst", ",", "nil", ",", "namespace", ")", "\n", "}" ]
// QueryNamespace invokes Query with the given namespace on the local machine.
[ "QueryNamespace", "invokes", "Query", "with", "the", "given", "namespace", "on", "the", "local", "machine", "." ]
e0a55b97c70558c92ce14085e41b35a894e93d3d
https://github.com/StackExchange/wmi/blob/e0a55b97c70558c92ce14085e41b35a894e93d3d/wmi.go#L58-L60
19,490
StackExchange/wmi
wmi.go
CreateQuery
func CreateQuery(src interface{}, where string) string { var b bytes.Buffer b.WriteString("SELECT ") s := reflect.Indirect(reflect.ValueOf(src)) t := s.Type() if s.Kind() == reflect.Slice { t = t.Elem() } if t.Kind() != reflect.Struct { return "" } var fields []string for i := 0; i < t.NumField(); i++ { ...
go
func CreateQuery(src interface{}, where string) string { var b bytes.Buffer b.WriteString("SELECT ") s := reflect.Indirect(reflect.ValueOf(src)) t := s.Type() if s.Kind() == reflect.Slice { t = t.Elem() } if t.Kind() != reflect.Struct { return "" } var fields []string for i := 0; i < t.NumField(); i++ { ...
[ "func", "CreateQuery", "(", "src", "interface", "{", "}", ",", "where", "string", ")", "string", "{", "var", "b", "bytes", ".", "Buffer", "\n", "b", ".", "WriteString", "(", "\"", "\"", ")", "\n", "s", ":=", "reflect", ".", "Indirect", "(", "reflect"...
// CreateQuery returns a WQL query string that queries all columns of src. where // is an optional string that is appended to the query, to be used with WHERE // clauses. In such a case, the "WHERE" string should appear at the beginning.
[ "CreateQuery", "returns", "a", "WQL", "query", "string", "that", "queries", "all", "columns", "of", "src", ".", "where", "is", "an", "optional", "string", "that", "is", "appended", "to", "the", "query", "to", "be", "used", "with", "WHERE", "clauses", ".", ...
e0a55b97c70558c92ce14085e41b35a894e93d3d
https://github.com/StackExchange/wmi/blob/e0a55b97c70558c92ce14085e41b35a894e93d3d/wmi.go#L470-L490
19,491
StackExchange/wmi
swbemservices.go
InitializeSWbemServices
func InitializeSWbemServices(c *Client, connectServerArgs ...interface{}) (*SWbemServices, error) { //fmt.Println("InitializeSWbemServices: Starting") //TODO: implement connectServerArgs as optional argument for init with connectServer call s := new(SWbemServices) s.cWMIClient = c s.queries = make(chan *queryReque...
go
func InitializeSWbemServices(c *Client, connectServerArgs ...interface{}) (*SWbemServices, error) { //fmt.Println("InitializeSWbemServices: Starting") //TODO: implement connectServerArgs as optional argument for init with connectServer call s := new(SWbemServices) s.cWMIClient = c s.queries = make(chan *queryReque...
[ "func", "InitializeSWbemServices", "(", "c", "*", "Client", ",", "connectServerArgs", "...", "interface", "{", "}", ")", "(", "*", "SWbemServices", ",", "error", ")", "{", "//fmt.Println(\"InitializeSWbemServices: Starting\")", "//TODO: implement connectServerArgs as option...
// InitializeSWbemServices will return a new SWbemServices object that can be used to query WMI
[ "InitializeSWbemServices", "will", "return", "a", "new", "SWbemServices", "object", "that", "can", "be", "used", "to", "query", "WMI" ]
e0a55b97c70558c92ce14085e41b35a894e93d3d
https://github.com/StackExchange/wmi/blob/e0a55b97c70558c92ce14085e41b35a894e93d3d/swbemservices.go#L34-L49
19,492
StackExchange/wmi
swbemservices.go
Close
func (s *SWbemServices) Close() error { s.lQueryorClose.Lock() if s == nil || s.sWbemLocatorIDispatch == nil { s.lQueryorClose.Unlock() return fmt.Errorf("SWbemServices is not Initialized") } if s.queries == nil { s.lQueryorClose.Unlock() return fmt.Errorf("SWbemServices has been closed") } //fmt.Println(...
go
func (s *SWbemServices) Close() error { s.lQueryorClose.Lock() if s == nil || s.sWbemLocatorIDispatch == nil { s.lQueryorClose.Unlock() return fmt.Errorf("SWbemServices is not Initialized") } if s.queries == nil { s.lQueryorClose.Unlock() return fmt.Errorf("SWbemServices has been closed") } //fmt.Println(...
[ "func", "(", "s", "*", "SWbemServices", ")", "Close", "(", ")", "error", "{", "s", ".", "lQueryorClose", ".", "Lock", "(", ")", "\n", "if", "s", "==", "nil", "||", "s", ".", "sWbemLocatorIDispatch", "==", "nil", "{", "s", ".", "lQueryorClose", ".", ...
// Close will clear and release all of the SWbemServices resources
[ "Close", "will", "clear", "and", "release", "all", "of", "the", "SWbemServices", "resources" ]
e0a55b97c70558c92ce14085e41b35a894e93d3d
https://github.com/StackExchange/wmi/blob/e0a55b97c70558c92ce14085e41b35a894e93d3d/swbemservices.go#L52-L74
19,493
coreos/ignition
internal/systemd/systemd.go
WaitOnDevices
func WaitOnDevices(devs []string, stage string) error { conn, err := dbus.NewSystemdConnection() if err != nil { return err } results := map[string]chan string{} for _, dev := range devs { unitName := unit.UnitNamePathEscape(dev + ".device") results[unitName] = make(chan string, 1) if _, err = conn.Start...
go
func WaitOnDevices(devs []string, stage string) error { conn, err := dbus.NewSystemdConnection() if err != nil { return err } results := map[string]chan string{} for _, dev := range devs { unitName := unit.UnitNamePathEscape(dev + ".device") results[unitName] = make(chan string, 1) if _, err = conn.Start...
[ "func", "WaitOnDevices", "(", "devs", "[", "]", "string", ",", "stage", "string", ")", "error", "{", "conn", ",", "err", ":=", "dbus", ".", "NewSystemdConnection", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "re...
// WaitOnDevices waits for the devices named in devs to be plugged before returning.
[ "WaitOnDevices", "waits", "for", "the", "devices", "named", "in", "devs", "to", "be", "plugged", "before", "returning", "." ]
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/systemd/systemd.go#L25-L50
19,494
coreos/ignition
config/config.go
Parse
func Parse(raw []byte) (types_exp.Config, report.Report, error) { if len(raw) == 0 { return types_exp.Config{}, report.Report{}, errors.ErrEmpty } stub := versionStub{} rpt, err := util.HandleParseErrors(raw, &stub) if err != nil { return types_exp.Config{}, rpt, err } version, err := semver.NewVersion(stu...
go
func Parse(raw []byte) (types_exp.Config, report.Report, error) { if len(raw) == 0 { return types_exp.Config{}, report.Report{}, errors.ErrEmpty } stub := versionStub{} rpt, err := util.HandleParseErrors(raw, &stub) if err != nil { return types_exp.Config{}, rpt, err } version, err := semver.NewVersion(stu...
[ "func", "Parse", "(", "raw", "[", "]", "byte", ")", "(", "types_exp", ".", "Config", ",", "report", ".", "Report", ",", "error", ")", "{", "if", "len", "(", "raw", ")", "==", "0", "{", "return", "types_exp", ".", "Config", "{", "}", ",", "report"...
// Parse parses a config of any supported version and returns the equivalent config at the latest // supported version.
[ "Parse", "parses", "a", "config", "of", "any", "supported", "version", "and", "returns", "the", "equivalent", "config", "at", "the", "latest", "supported", "version", "." ]
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/config/config.go#L38-L62
19,495
coreos/ignition
internal/resource/url.go
FetchToBuffer
func (f *Fetcher) FetchToBuffer(u url.URL, opts FetchOptions) ([]byte, error) { file, err := ioutil.TempFile("", "ignition") if err != nil { return nil, err } defer os.Remove(file.Name()) defer file.Close() err = f.Fetch(u, file, opts) if err != nil { return nil, err } _, err = file.Seek(0, os.SEEK_SET) i...
go
func (f *Fetcher) FetchToBuffer(u url.URL, opts FetchOptions) ([]byte, error) { file, err := ioutil.TempFile("", "ignition") if err != nil { return nil, err } defer os.Remove(file.Name()) defer file.Close() err = f.Fetch(u, file, opts) if err != nil { return nil, err } _, err = file.Seek(0, os.SEEK_SET) i...
[ "func", "(", "f", "*", "Fetcher", ")", "FetchToBuffer", "(", "u", "url", ".", "URL", ",", "opts", "FetchOptions", ")", "(", "[", "]", "byte", ",", "error", ")", "{", "file", ",", "err", ":=", "ioutil", ".", "TempFile", "(", "\"", "\"", ",", "\"",...
// FetchToBuffer will fetch the given url into a temporrary file, and then read // in the contents of the file and delete it. It will return the downloaded // contents, or an error if one was encountered.
[ "FetchToBuffer", "will", "fetch", "the", "given", "url", "into", "a", "temporrary", "file", "and", "then", "read", "in", "the", "contents", "of", "the", "file", "and", "delete", "it", ".", "It", "will", "return", "the", "downloaded", "contents", "or", "an"...
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/resource/url.go#L102-L122
19,496
coreos/ignition
internal/resource/url.go
FetchFromTFTP
func (f *Fetcher) FetchFromTFTP(u url.URL, dest *os.File, opts FetchOptions) error { if !strings.ContainsRune(u.Host, ':') { u.Host = u.Host + ":69" } c, err := tftp.NewClient(u.Host) if err != nil { return err } wt, err := c.Receive(u.Path, "octet") if err != nil { return err } // The TFTP library takes...
go
func (f *Fetcher) FetchFromTFTP(u url.URL, dest *os.File, opts FetchOptions) error { if !strings.ContainsRune(u.Host, ':') { u.Host = u.Host + ":69" } c, err := tftp.NewClient(u.Host) if err != nil { return err } wt, err := c.Receive(u.Path, "octet") if err != nil { return err } // The TFTP library takes...
[ "func", "(", "f", "*", "Fetcher", ")", "FetchFromTFTP", "(", "u", "url", ".", "URL", ",", "dest", "*", "os", ".", "File", ",", "opts", "FetchOptions", ")", "error", "{", "if", "!", "strings", ".", "ContainsRune", "(", "u", ".", "Host", ",", "':'", ...
// FetchFromTFTP fetches a resource from u via TFTP into dest, returning an // error if one is encountered.
[ "FetchFromTFTP", "fetches", "a", "resource", "from", "u", "via", "TFTP", "into", "dest", "returning", "an", "error", "if", "one", "is", "encountered", "." ]
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/resource/url.go#L153-L211
19,497
coreos/ignition
internal/resource/url.go
FetchFromDataURL
func (f *Fetcher) FetchFromDataURL(u url.URL, dest *os.File, opts FetchOptions) error { if opts.Compression != "" { return ErrCompressionUnsupported } url, err := dataurl.DecodeString(u.String()) if err != nil { return err } return f.decompressCopyHashAndVerify(dest, bytes.NewBuffer(url.Data), opts) }
go
func (f *Fetcher) FetchFromDataURL(u url.URL, dest *os.File, opts FetchOptions) error { if opts.Compression != "" { return ErrCompressionUnsupported } url, err := dataurl.DecodeString(u.String()) if err != nil { return err } return f.decompressCopyHashAndVerify(dest, bytes.NewBuffer(url.Data), opts) }
[ "func", "(", "f", "*", "Fetcher", ")", "FetchFromDataURL", "(", "u", "url", ".", "URL", ",", "dest", "*", "os", ".", "File", ",", "opts", "FetchOptions", ")", "error", "{", "if", "opts", ".", "Compression", "!=", "\"", "\"", "{", "return", "ErrCompre...
// FetchFromDataURL writes the data stored in the dataurl u into dest, returning // an error if one is encountered.
[ "FetchFromDataURL", "writes", "the", "data", "stored", "in", "the", "dataurl", "u", "into", "dest", "returning", "an", "error", "if", "one", "is", "encountered", "." ]
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/resource/url.go#L251-L261
19,498
coreos/ignition
internal/resource/url.go
FetchFromS3
func (f *Fetcher) FetchFromS3(u url.URL, dest *os.File, opts FetchOptions) error { if opts.Compression != "" { return ErrCompressionUnsupported } ctx := context.Background() if f.client != nil && f.client.timeout != 0 { var cancelFn context.CancelFunc ctx, cancelFn = context.WithTimeout(ctx, f.client.timeout)...
go
func (f *Fetcher) FetchFromS3(u url.URL, dest *os.File, opts FetchOptions) error { if opts.Compression != "" { return ErrCompressionUnsupported } ctx := context.Background() if f.client != nil && f.client.timeout != 0 { var cancelFn context.CancelFunc ctx, cancelFn = context.WithTimeout(ctx, f.client.timeout)...
[ "func", "(", "f", "*", "Fetcher", ")", "FetchFromS3", "(", "u", "url", ".", "URL", ",", "dest", "*", "os", ".", "File", ",", "opts", "FetchOptions", ")", "error", "{", "if", "opts", ".", "Compression", "!=", "\"", "\"", "{", "return", "ErrCompression...
// FetchFromS3 gets data from an S3 bucket as described by u and writes it into // dest, returning an error if one is encountered. It will attempt to acquire // IAM credentials from the EC2 metadata service, and if this fails will attempt // to fetch the object with anonymous credentials.
[ "FetchFromS3", "gets", "data", "from", "an", "S3", "bucket", "as", "described", "by", "u", "and", "writes", "it", "into", "dest", "returning", "an", "error", "if", "one", "is", "encountered", ".", "It", "will", "attempt", "to", "acquire", "IAM", "credentia...
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/resource/url.go#L267-L338
19,499
coreos/ignition
internal/resource/url.go
uncompress
func (f *Fetcher) uncompress(r io.Reader, opts FetchOptions) (io.ReadCloser, error) { switch opts.Compression { case "": return ioutil.NopCloser(r), nil case "gzip": return gzip.NewReader(r) default: return nil, configErrors.ErrCompressionInvalid } }
go
func (f *Fetcher) uncompress(r io.Reader, opts FetchOptions) (io.ReadCloser, error) { switch opts.Compression { case "": return ioutil.NopCloser(r), nil case "gzip": return gzip.NewReader(r) default: return nil, configErrors.ErrCompressionInvalid } }
[ "func", "(", "f", "*", "Fetcher", ")", "uncompress", "(", "r", "io", ".", "Reader", ",", "opts", "FetchOptions", ")", "(", "io", ".", "ReadCloser", ",", "error", ")", "{", "switch", "opts", ".", "Compression", "{", "case", "\"", "\"", ":", "return", ...
// uncompress will wrap the given io.Reader in a decompresser specified in the // FetchOptions, and return an io.ReadCloser with the decompressed data stream.
[ "uncompress", "will", "wrap", "the", "given", "io", ".", "Reader", "in", "a", "decompresser", "specified", "in", "the", "FetchOptions", "and", "return", "an", "io", ".", "ReadCloser", "with", "the", "decompressed", "data", "stream", "." ]
1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9
https://github.com/coreos/ignition/blob/1eeb201e9e6045383cba2e37ad53b3f49ca7b5a9/internal/resource/url.go#L363-L372