github.com/projecteru2/core@v0.0.0-20240321043226-06bcc1c23f58/wal/wal.go (about) 1 package wal 2 3 import ( 4 "context" 5 ) 6 7 const ( 8 eventPrefix = "/events/" 9 ) 10 11 // WAL is the interface that groups the Register and Recover interfaces. 12 type WAL interface { 13 Registry 14 Recoverer 15 Logger 16 Closer 17 } 18 19 // Recoverer is the interface that wraps the basic Recover method. 20 type Recoverer interface { 21 Recover(context.Context) 22 } 23 24 // Registry is the interface that wraps the basic Register method. 25 type Registry interface { 26 Register(EventHandler) 27 } 28 29 // Logger is the interface that wraps the basic Log method. 30 type Logger interface { 31 Log(string, any) (Commit, error) 32 } 33 34 // Closer is the interface that groups the Close methods. 35 type Closer interface { 36 Close() error 37 } 38 39 // EventHandler is the interface that groups a few methods. 40 type EventHandler interface { 41 Typ() string 42 Check(context.Context, any) (need bool, err error) 43 Encode(any) ([]byte, error) 44 Decode([]byte) (any, error) 45 Handle(context.Context, any) error 46 } 47 48 // Commit is a function for committing an event log 49 type Commit func() error