offline

package
v1.85.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 8, 2023 License: BSD-3-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// PrintMaxDefault is the default maximum number of heartbeats to print.
	PrintMaxDefault = 10
	// SendLimit is the maximum number of heartbeats, which will be sent at once
	// to the WakaTime API.
	SendLimit = 25
	// SyncMaxDefault is the default maximum number of heartbeats from the
	// offline queue, which will be synced upon sending heartbeats to the API.
	SyncMaxDefault = 1000
)

Variables

This section is empty.

Functions

func CountHeartbeats added in v1.18.1

func CountHeartbeats(filepath string) (int, error)

CountHeartbeats returns the total number of heartbeats in the offline db.

func QueueFilepath

func QueueFilepath() (string, error)

QueueFilepath returns the path for offline queue db file. If the user's $HOME folder cannot be detected, it defaults to the current directory.

func ReadHeartbeats added in v1.45.1

func ReadHeartbeats(filepath string, limit int) ([]heartbeat.Heartbeat, error)

ReadHeartbeats reads the informed heartbeats in the offline db.

func Sync added in v1.18.1

func Sync(filepath string, syncLimit int) func(next heartbeat.Handle) error

Sync returns a function to send queued heartbeats to the WakaTime API.

func WithQueue

func WithQueue(filepath string) heartbeat.HandleOption

WithQueue initializes and returns a heartbeat handle option, which can be used in a heartbeat processing pipeline for automatic handling of failures of heartbeat sending to the API. Upon inability to send due to missing or failing connection to API, failed sending or errors returned by API, the heartbeats will be temporarily stored in a DB and sending will be retried at next usages of the wakatime cli.

func WithSync added in v1.42.1

func WithSync(filepath string, syncLimit int) heartbeat.HandleOption

WithSync initializes and returns a heartbeat handle option, which can be used in a heartbeat processing pipeline to pop heartbeats from offline queue and send the heartbeats to WakaTime API.

Types

type ErrOpenDB added in v1.73.3

type ErrOpenDB struct {
	Err error
}

ErrOpenDB is an error returned when the database cannot be opened.

func (ErrOpenDB) Error added in v1.73.3

func (e ErrOpenDB) Error() string

Error method to implement error interface.

func (ErrOpenDB) ExitCode added in v1.73.3

func (ErrOpenDB) ExitCode() int

ExitCode method to implement wakaerror.Error interface.

func (ErrOpenDB) Message added in v1.73.3

func (e ErrOpenDB) Message() string

Message method to implement wakaerror.Error interface.

func (ErrOpenDB) SendDiagsOnErrors added in v1.73.3

func (ErrOpenDB) SendDiagsOnErrors() bool

SendDiagsOnErrors method to implement wakaerror.SendDiagsOnErrors interface.

func (ErrOpenDB) ShouldLogError added in v1.73.3

func (ErrOpenDB) ShouldLogError() bool

ShouldLogError method to implement wakaerror.ShouldLogError interface.

type Noop added in v1.44.0

type Noop struct{}

Noop is a noop api client, used by offline.SaveHeartbeats.

func (Noop) SendHeartbeats added in v1.44.0

func (Noop) SendHeartbeats(_ []heartbeat.Heartbeat) ([]heartbeat.Result, error)

SendHeartbeats always returns an error.

type Queue

type Queue struct {
	Bucket string
	// contains filtered or unexported fields
}

Queue is a db client to temporarily store heartbeats in bolt db, in case heartbeat sending to wakatime api is not possible. Transaction handling is left to the user via the passed in transaction.

func NewQueue

func NewQueue(tx *bolt.Tx) *Queue

NewQueue creates a new instance of Queue.

func (*Queue) Count added in v1.18.1

func (q *Queue) Count() (int, error)

Count returns the total number of heartbeats in the offline db.

func (*Queue) PopMany

func (q *Queue) PopMany(limit int) ([]heartbeat.Heartbeat, error)

PopMany retrieves heartbeats with the specified ids from db.

func (*Queue) PushMany

func (q *Queue) PushMany(hh []heartbeat.Heartbeat) error

PushMany stores the provided heartbeats in the db.

func (*Queue) ReadMany added in v1.45.1

func (q *Queue) ReadMany(limit int) ([]heartbeat.Heartbeat, error)

ReadMany reads heartbeats from db without deleting them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL