Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ActivityTracker ¶
type ActivityTracker struct {
// contains filtered or unexported fields
}
ActivityTracker remembers active tasks in the file. If file already exists, it is recreated from scratch. Activity tracker uses mmap to write to the file, which allows fast writes because it's only using memory access, with no system calls. Nil activity tracker ignores all calls to its public API.
func NewActivityTracker ¶
func NewActivityTracker(cfg Config, reg prometheus.Registerer) (*ActivityTracker, error)
func (*ActivityTracker) Close ¶
func (t *ActivityTracker) Close() error
Close closes activity tracker. Calling other methods after Close() will likely panic. Don't do that.
func (*ActivityTracker) Delete ¶
func (t *ActivityTracker) Delete(activityIndex int)
Delete removes activity with given index (returned previously by Insert) from the tracker. Should only be called once for each activity, as indexes are reused. It is OK to call Delete with negative index, which is returned by Insert when activity couldn't be inserted.
func (*ActivityTracker) Insert ¶
func (t *ActivityTracker) Insert(activityGenerator func() string) (activityIndex int)
Insert inserts entry (generated by activityGenerator) into the activity tracker. If tracker is full, activityGenerator is not called. Value returned by Insert is to be used with Delete method after activity has finished.
String returned by activityGenerator should be human-readable description of activity. If it is bigger than max entry size, it will be trimmed on latest utf-8 rune start before the limit.
Note that timestamp of Insert call is stored automatically with the tracked activity.
func (*ActivityTracker) InsertStatic ¶
func (t *ActivityTracker) InsertStatic(activity string) (activityIndex int)