Added ReadOptions; Changed proto; Reimplemented Log(er)

This commit is contained in:
Milos Gajdos
2019-11-27 17:31:35 +00:00
parent 9e177be560
commit 7deafbc5ce
8 changed files with 195 additions and 115 deletions

View File

@@ -1,5 +1,7 @@
package log
import "time"
// Option used by the logger
type Option func(*Options)
@@ -22,3 +24,28 @@ func DefaultOptions() Options {
Size: DefaultSize,
}
}
// ReadOptions for querying the logs
type ReadOptions struct {
// Since what time in past to return the logs
Since time.Time
// Count specifies number of logs to return
Count int
}
// ReadOption used for reading the logs
type ReadOption func(*ReadOptions)
// Since sets the time since which to return the log records
func Since(s time.Time) ReadOption {
return func(o *ReadOptions) {
o.Since = s
}
}
// Count sets the number of log records to return
func Count(c int) ReadOption {
return func(o *ReadOptions) {
o.Count = c
}
}