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
listlengths
21
1.41k
docstring
stringlengths
6
2.61k
docstring_tokens
listlengths
3
215
sha
stringlengths
40
40
url
stringlengths
85
252
141,400
mdlayher/netlink
conn_linux.go
SendMessages
func (c *conn) SendMessages(messages []Message) error { var buf []byte for _, m := range messages { b, err := m.MarshalBinary() if err != nil { return err } buf = append(buf, b...) } addr := &unix.SockaddrNetlink{ Family: unix.AF_NETLINK, } return os.NewSyscallError("sendmsg", c.s.Sendmsg(buf, nil...
go
func (c *conn) SendMessages(messages []Message) error { var buf []byte for _, m := range messages { b, err := m.MarshalBinary() if err != nil { return err } buf = append(buf, b...) } addr := &unix.SockaddrNetlink{ Family: unix.AF_NETLINK, } return os.NewSyscallError("sendmsg", c.s.Sendmsg(buf, nil...
[ "func", "(", "c", "*", "conn", ")", "SendMessages", "(", "messages", "[", "]", "Message", ")", "error", "{", "var", "buf", "[", "]", "byte", "\n", "for", "_", ",", "m", ":=", "range", "messages", "{", "b", ",", "err", ":=", "m", ".", "MarshalBina...
// SendMessages serializes multiple Messages and sends them to netlink.
[ "SendMessages", "serializes", "multiple", "Messages", "and", "sends", "them", "to", "netlink", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L106-L122
141,401
mdlayher/netlink
conn_linux.go
Send
func (c *conn) Send(m Message) error { b, err := m.MarshalBinary() if err != nil { return err } addr := &unix.SockaddrNetlink{ Family: unix.AF_NETLINK, } return os.NewSyscallError("sendmsg", c.s.Sendmsg(b, nil, addr, 0)) }
go
func (c *conn) Send(m Message) error { b, err := m.MarshalBinary() if err != nil { return err } addr := &unix.SockaddrNetlink{ Family: unix.AF_NETLINK, } return os.NewSyscallError("sendmsg", c.s.Sendmsg(b, nil, addr, 0)) }
[ "func", "(", "c", "*", "conn", ")", "Send", "(", "m", "Message", ")", "error", "{", "b", ",", "err", ":=", "m", ".", "MarshalBinary", "(", ")", "\n", "if", "err", "!=", "nil", "{", "return", "err", "\n", "}", "\n\n", "addr", ":=", "&", "unix", ...
// Send sends a single Message to netlink.
[ "Send", "sends", "a", "single", "Message", "to", "netlink", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L125-L136
141,402
mdlayher/netlink
conn_linux.go
Receive
func (c *conn) Receive() ([]Message, error) { b := make([]byte, os.Getpagesize()) for { // Peek at the buffer to see how many bytes are available. // // TODO(mdlayher): deal with OOB message data if available, such as // when PacketInfo ConnOption is true. n, _, _, _, err := c.s.Recvmsg(b, nil, unix.MSG_PEE...
go
func (c *conn) Receive() ([]Message, error) { b := make([]byte, os.Getpagesize()) for { // Peek at the buffer to see how many bytes are available. // // TODO(mdlayher): deal with OOB message data if available, such as // when PacketInfo ConnOption is true. n, _, _, _, err := c.s.Recvmsg(b, nil, unix.MSG_PEE...
[ "func", "(", "c", "*", "conn", ")", "Receive", "(", ")", "(", "[", "]", "Message", ",", "error", ")", "{", "b", ":=", "make", "(", "[", "]", "byte", ",", "os", ".", "Getpagesize", "(", ")", ")", "\n", "for", "{", "// Peek at the buffer to see how m...
// Receive receives one or more Messages from netlink.
[ "Receive", "receives", "one", "or", "more", "Messages", "from", "netlink", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L139-L184
141,403
mdlayher/netlink
conn_linux.go
JoinGroup
func (c *conn) JoinGroup(group uint32) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_NETLINK, unix.NETLINK_ADD_MEMBERSHIP, int(group), )) }
go
func (c *conn) JoinGroup(group uint32) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_NETLINK, unix.NETLINK_ADD_MEMBERSHIP, int(group), )) }
[ "func", "(", "c", "*", "conn", ")", "JoinGroup", "(", "group", "uint32", ")", "error", "{", "return", "os", ".", "NewSyscallError", "(", "\"", "\"", ",", "c", ".", "s", ".", "SetSockoptInt", "(", "unix", ".", "SOL_NETLINK", ",", "unix", ".", "NETLINK...
// JoinGroup joins a multicast group by ID.
[ "JoinGroup", "joins", "a", "multicast", "group", "by", "ID", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L202-L208
141,404
mdlayher/netlink
conn_linux.go
LeaveGroup
func (c *conn) LeaveGroup(group uint32) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_NETLINK, unix.NETLINK_DROP_MEMBERSHIP, int(group), )) }
go
func (c *conn) LeaveGroup(group uint32) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_NETLINK, unix.NETLINK_DROP_MEMBERSHIP, int(group), )) }
[ "func", "(", "c", "*", "conn", ")", "LeaveGroup", "(", "group", "uint32", ")", "error", "{", "return", "os", ".", "NewSyscallError", "(", "\"", "\"", ",", "c", ".", "s", ".", "SetSockoptInt", "(", "unix", ".", "SOL_NETLINK", ",", "unix", ".", "NETLIN...
// LeaveGroup leaves a multicast group by ID.
[ "LeaveGroup", "leaves", "a", "multicast", "group", "by", "ID", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L211-L217
141,405
mdlayher/netlink
conn_linux.go
SetBPF
func (c *conn) SetBPF(filter []bpf.RawInstruction) error { prog := unix.SockFprog{ Len: uint16(len(filter)), Filter: (*unix.SockFilter)(unsafe.Pointer(&filter[0])), } return os.NewSyscallError("setsockopt", c.s.SetSockoptSockFprog( unix.SOL_SOCKET, unix.SO_ATTACH_FILTER, &prog, )) }
go
func (c *conn) SetBPF(filter []bpf.RawInstruction) error { prog := unix.SockFprog{ Len: uint16(len(filter)), Filter: (*unix.SockFilter)(unsafe.Pointer(&filter[0])), } return os.NewSyscallError("setsockopt", c.s.SetSockoptSockFprog( unix.SOL_SOCKET, unix.SO_ATTACH_FILTER, &prog, )) }
[ "func", "(", "c", "*", "conn", ")", "SetBPF", "(", "filter", "[", "]", "bpf", ".", "RawInstruction", ")", "error", "{", "prog", ":=", "unix", ".", "SockFprog", "{", "Len", ":", "uint16", "(", "len", "(", "filter", ")", ")", ",", "Filter", ":", "(...
// SetBPF attaches an assembled BPF program to a conn.
[ "SetBPF", "attaches", "an", "assembled", "BPF", "program", "to", "a", "conn", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L220-L231
141,406
mdlayher/netlink
conn_linux.go
RemoveBPF
func (c *conn) RemoveBPF() error { // 0 argument is ignored by SO_DETACH_FILTER. return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_SOCKET, unix.SO_DETACH_FILTER, 0, )) }
go
func (c *conn) RemoveBPF() error { // 0 argument is ignored by SO_DETACH_FILTER. return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_SOCKET, unix.SO_DETACH_FILTER, 0, )) }
[ "func", "(", "c", "*", "conn", ")", "RemoveBPF", "(", ")", "error", "{", "// 0 argument is ignored by SO_DETACH_FILTER.", "return", "os", ".", "NewSyscallError", "(", "\"", "\"", ",", "c", ".", "s", ".", "SetSockoptInt", "(", "unix", ".", "SOL_SOCKET", ",", ...
// RemoveBPF removes a BPF filter from a conn.
[ "RemoveBPF", "removes", "a", "BPF", "filter", "from", "a", "conn", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L234-L241
141,407
mdlayher/netlink
conn_linux.go
SetWriteBuffer
func (c *conn) SetWriteBuffer(bytes int) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_SOCKET, unix.SO_SNDBUF, bytes, )) }
go
func (c *conn) SetWriteBuffer(bytes int) error { return os.NewSyscallError("setsockopt", c.s.SetSockoptInt( unix.SOL_SOCKET, unix.SO_SNDBUF, bytes, )) }
[ "func", "(", "c", "*", "conn", ")", "SetWriteBuffer", "(", "bytes", "int", ")", "error", "{", "return", "os", ".", "NewSyscallError", "(", "\"", "\"", ",", "c", ".", "s", ".", "SetSockoptInt", "(", "unix", ".", "SOL_SOCKET", ",", "unix", ".", "SO_SND...
// SetReadBuffer sets the size of the operating system's transmit buffer // associated with the Conn.
[ "SetReadBuffer", "sets", "the", "size", "of", "the", "operating", "system", "s", "transmit", "buffer", "associated", "with", "the", "Conn", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L287-L293
141,408
mdlayher/netlink
conn_linux.go
linuxOption
func linuxOption(o ConnOption) (int, bool) { switch o { case PacketInfo: return unix.NETLINK_PKTINFO, true case BroadcastError: return unix.NETLINK_BROADCAST_ERROR, true case NoENOBUFS: return unix.NETLINK_NO_ENOBUFS, true case ListenAllNSID: return unix.NETLINK_LISTEN_ALL_NSID, true case CapAcknowledge: ...
go
func linuxOption(o ConnOption) (int, bool) { switch o { case PacketInfo: return unix.NETLINK_PKTINFO, true case BroadcastError: return unix.NETLINK_BROADCAST_ERROR, true case NoENOBUFS: return unix.NETLINK_NO_ENOBUFS, true case ListenAllNSID: return unix.NETLINK_LISTEN_ALL_NSID, true case CapAcknowledge: ...
[ "func", "linuxOption", "(", "o", "ConnOption", ")", "(", "int", ",", "bool", ")", "{", "switch", "o", "{", "case", "PacketInfo", ":", "return", "unix", ".", "NETLINK_PKTINFO", ",", "true", "\n", "case", "BroadcastError", ":", "return", "unix", ".", "NETL...
// linuxOption converts a ConnOption to its Linux value.
[ "linuxOption", "converts", "a", "ConnOption", "to", "its", "Linux", "value", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L296-L311
141,409
mdlayher/netlink
conn_linux.go
newSysSocket
func newSysSocket(config *Config) (*sysSocket, error) { g, err := newLockedNetNSGoroutine(config.NetNS) if err != nil { return nil, err } return &sysSocket{ g: g, }, nil }
go
func newSysSocket(config *Config) (*sysSocket, error) { g, err := newLockedNetNSGoroutine(config.NetNS) if err != nil { return nil, err } return &sysSocket{ g: g, }, nil }
[ "func", "newSysSocket", "(", "config", "*", "Config", ")", "(", "*", "sysSocket", ",", "error", ")", "{", "g", ",", "err", ":=", "newLockedNetNSGoroutine", "(", "config", ".", "NetNS", ")", "\n", "if", "err", "!=", "nil", "{", "return", "nil", ",", "...
// newSysSocket creates a sysSocket that optionally locks its internal goroutine // to a single thread.
[ "newSysSocket", "creates", "a", "sysSocket", "that", "optionally", "locks", "its", "internal", "goroutine", "to", "a", "single", "thread", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L338-L346
141,410
mdlayher/netlink
conn_linux.go
do
func (s *sysSocket) do(f func()) error { // All operations handled by this function are assumed to only // read from s.done. s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } s.g.run(f) return nil }
go
func (s *sysSocket) do(f func()) error { // All operations handled by this function are assumed to only // read from s.done. s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } s.g.run(f) return nil }
[ "func", "(", "s", "*", "sysSocket", ")", "do", "(", "f", "func", "(", ")", ")", "error", "{", "// All operations handled by this function are assumed to only", "// read from s.done.", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", "."...
// do runs f in a worker goroutine which can be locked to one thread.
[ "do", "runs", "f", "in", "a", "worker", "goroutine", "which", "can", "be", "locked", "to", "one", "thread", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L349-L361
141,411
mdlayher/netlink
conn_linux.go
read
func (s *sysSocket) read(f func(fd int) bool) error { s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } var err error s.g.run(func() { err = fdread(s.fd, f) }) return err }
go
func (s *sysSocket) read(f func(fd int) bool) error { s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } var err error s.g.run(func() { err = fdread(s.fd, f) }) return err }
[ "func", "(", "s", "*", "sysSocket", ")", "read", "(", "f", "func", "(", "fd", "int", ")", "bool", ")", "error", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "s", ".", "c...
// read executes f, a read function, against the associated file descriptor.
[ "read", "executes", "f", "a", "read", "function", "against", "the", "associated", "file", "descriptor", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L364-L377
141,412
mdlayher/netlink
conn_linux.go
control
func (s *sysSocket) control(f func(fd int)) error { s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } var err error s.g.run(func() { err = fdcontrol(s.fd, f) }) return err }
go
func (s *sysSocket) control(f func(fd int)) error { s.mu.RLock() defer s.mu.RUnlock() if s.closed { return syscall.EBADF } var err error s.g.run(func() { err = fdcontrol(s.fd, f) }) return err }
[ "func", "(", "s", "*", "sysSocket", ")", "control", "(", "f", "func", "(", "fd", "int", ")", ")", "error", "{", "s", ".", "mu", ".", "RLock", "(", ")", "\n", "defer", "s", ".", "mu", ".", "RUnlock", "(", ")", "\n\n", "if", "s", ".", "closed",...
// control executes f, a control function, against the associated file descriptor.
[ "control", "executes", "f", "a", "control", "function", "against", "the", "associated", "file", "descriptor", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L396-L409
141,413
mdlayher/netlink
conn_linux.go
run
func (g *lockedNetNSGoroutine) run(f func()) { done := make(chan struct{}) g.funcC <- func() { defer close(done) f() } <-done }
go
func (g *lockedNetNSGoroutine) run(f func()) { done := make(chan struct{}) g.funcC <- func() { defer close(done) f() } <-done }
[ "func", "(", "g", "*", "lockedNetNSGoroutine", ")", "run", "(", "f", "func", "(", ")", ")", "{", "done", ":=", "make", "(", "chan", "struct", "{", "}", ")", "\n", "g", ".", "funcC", "<-", "func", "(", ")", "{", "defer", "close", "(", "done", ")...
// run runs f on the worker goroutine.
[ "run", "runs", "f", "on", "the", "worker", "goroutine", "." ]
b540351f6c5108aa445eaa6677010703c7294f8d
https://github.com/mdlayher/netlink/blob/b540351f6c5108aa445eaa6677010703c7294f8d/conn_linux.go#L670-L677
141,414
looplab/eventhorizon
repo/version/repo.go
Find
func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error) { // If there is no min version set just return the item as normally. minVersion, ok := eh.MinVersionFromContext(ctx) if !ok || minVersion < 1 { return r.ReadWriteRepo.Find(ctx, id) } // Try to get the correct version, retry with exponent...
go
func (r *Repo) Find(ctx context.Context, id uuid.UUID) (eh.Entity, error) { // If there is no min version set just return the item as normally. minVersion, ok := eh.MinVersionFromContext(ctx) if !ok || minVersion < 1 { return r.ReadWriteRepo.Find(ctx, id) } // Try to get the correct version, retry with exponent...
[ "func", "(", "r", "*", "Repo", ")", "Find", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ")", "(", "eh", ".", "Entity", ",", "error", ")", "{", "// If there is no min version set just return the item as normally.", "minVersion", ",", ...
// Find implements the Find method of the eventhorizon.ReadModel interface. // If the context contains a min version set by WithMinVersion it will only // return an item if its version is at least min version. If a timeout or // deadline is set on the context it will repetedly try to get the item until // either the ve...
[ "Find", "implements", "the", "Find", "method", "of", "the", "eventhorizon", ".", "ReadModel", "interface", ".", "If", "the", "context", "contains", "a", "min", "version", "set", "by", "WithMinVersion", "it", "will", "only", "return", "an", "item", "if", "its...
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/version/repo.go#L48-L83
141,415
looplab/eventhorizon
repo/version/repo.go
findMinVersion
func (r *Repo) findMinVersion(ctx context.Context, id uuid.UUID, minVersion int) (eh.Entity, error) { entity, err := r.ReadWriteRepo.Find(ctx, id) if err != nil { return nil, err } versionable, ok := entity.(eh.Versionable) if !ok { return nil, eh.RepoError{ Err: eh.ErrEntityHasNoVersion, Namespac...
go
func (r *Repo) findMinVersion(ctx context.Context, id uuid.UUID, minVersion int) (eh.Entity, error) { entity, err := r.ReadWriteRepo.Find(ctx, id) if err != nil { return nil, err } versionable, ok := entity.(eh.Versionable) if !ok { return nil, eh.RepoError{ Err: eh.ErrEntityHasNoVersion, Namespac...
[ "func", "(", "r", "*", "Repo", ")", "findMinVersion", "(", "ctx", "context", ".", "Context", ",", "id", "uuid", ".", "UUID", ",", "minVersion", "int", ")", "(", "eh", ".", "Entity", ",", "error", ")", "{", "entity", ",", "err", ":=", "r", ".", "R...
// findMinVersion finds an item if it has a version and it is at least minVersion.
[ "findMinVersion", "finds", "an", "item", "if", "it", "has", "a", "version", "and", "it", "is", "at", "least", "minVersion", "." ]
6fd1f17be266c5a217ff8c05dd1403d722cae7f2
https://github.com/looplab/eventhorizon/blob/6fd1f17be266c5a217ff8c05dd1403d722cae7f2/repo/version/repo.go#L86-L108
141,416
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
141,417
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
141,418
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
141,419
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
141,420
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
141,421
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
141,422
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
141,423
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
141,424
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
141,425
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
141,426
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
141,427
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
141,428
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
141,429
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
141,430
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
141,431
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
141,432
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
141,433
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
141,434
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
141,435
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
141,436
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
141,437
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
141,438
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
141,439
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
141,440
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
141,441
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
141,442
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
141,443
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
141,444
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
141,445
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
141,446
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
141,447
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
141,448
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
141,449
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
141,450
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
141,451
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
141,452
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
141,453
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
141,454
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
141,455
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
141,456
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
141,457
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
141,458
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
141,459
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
141,460
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
141,461
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
141,462
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
141,463
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
141,464
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
141,465
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
141,466
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
141,467
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
141,468
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
141,469
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
141,470
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
141,471
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
141,472
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
141,473
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
141,474
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
141,475
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
141,476
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
141,477
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
141,478
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
141,479
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
141,480
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
141,481
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
141,482
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
141,483
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
141,484
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
141,485
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
141,486
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
141,487
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
141,488
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
141,489
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
141,490
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
141,491
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
141,492
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
141,493
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
141,494
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
141,495
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
141,496
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
141,497
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
141,498
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
141,499
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