Documentation ¶
Index ¶
- Variables
- func MergeNewTaskSet(oldTasks []*task.LocalTask, newTasks []*task.Task) []*task.LocalTask
- func NextLocalId(used []int) int
- type Dispatcher
- type LocalRepository
- type Memory
- func (m *Memory) Add(update *task.LocalUpdate) (*task.LocalTask, error)
- func (m *Memory) FindAll() ([]*task.LocalTask, error)
- func (m *Memory) FindById(id string) (*task.LocalTask, error)
- func (m *Memory) FindByLocalId(localId int) (*task.LocalTask, error)
- func (m *Memory) LatestSyncs() (time.Time, time.Time, error)
- func (m *Memory) MarkDispatched(localId int) error
- func (m *Memory) SetLocalUpdate(id string, update *task.LocalUpdate) error
- func (m *Memory) SetTasks(tasks []*task.Task) error
- type RemoteRepository
- type Sqlite
- func (s *Sqlite) Add(update *task.LocalUpdate) (*task.LocalTask, error)
- func (s *Sqlite) FindAll() ([]*task.LocalTask, error)
- func (s *Sqlite) FindById(id string) (*task.LocalTask, error)
- func (s *Sqlite) FindByLocalId(localId int) (*task.LocalTask, error)
- func (s *Sqlite) LatestSyncs() (time.Time, time.Time, error)
- func (s *Sqlite) MarkDispatched(localId int) error
- func (s *Sqlite) SetLocalUpdate(id string, update *task.LocalUpdate) error
- func (s *Sqlite) SetTasks(tasks []*task.Task) error
- type SqliteConfig
Constants ¶
This section is empty.
Variables ¶
var ( ErrMStoreError = errors.New("mstore gave error response") ErrInvalidTask = errors.New("invalid task") ErrInvalidMessage = errors.New("task contains invalid message") )
Functions ¶
func MergeNewTaskSet ¶
MergeNewTaskSet updates a local set of tasks with a remote one
The new set is leading and tasks that are not in there get dismissed. Tasks that were created locally and got dispatched might temporarily dissappear if the remote inbox has a delay in processing.
func NextLocalId ¶
NextLocalId finds a new local id by incrememting to a variable limit.
When tasks are edited, some get removed because they are done or deleted. It is very confusing if existing tasks get renumbered, or if a new one immediatly gets the id of an removed one. So it is better to just increment. However, local id's also benefit from being short, so we don't want to keep incrementing forever.
This function takes a list if id's that are in use and sets the limit to the nearest power of ten depening on the current highest id used. The new id is an incremented one from that max. However, if the limit is reached, it first tries to find "holes" in the current sequence, starting from the bottom. If there are no holes, the limit is increased.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
func NewDispatcher ¶
func NewDispatcher(msender msend.MSender) *Dispatcher
func (*Dispatcher) Dispatch ¶
func (d *Dispatcher) Dispatch(t *task.Task) error
type LocalRepository ¶
type LocalRepository interface { LatestSyncs() (time.Time, time.Time, error) // last fetch, last dispatch, err SetTasks(tasks []*task.Task) error FindAll() ([]*task.LocalTask, error) FindById(id string) (*task.LocalTask, error) FindByLocalId(id int) (*task.LocalTask, error) SetLocalUpdate(id string, update *task.LocalUpdate) error MarkDispatched(id int) error Add(update *task.LocalUpdate) (*task.LocalTask, error) }
type Memory ¶
type Memory struct {
// contains filtered or unexported fields
}
Memory is an in memory implementation of LocalRepository
type RemoteRepository ¶
type RemoteRepository struct {
// contains filtered or unexported fields
}
func NewRemoteRepository ¶
func NewRemoteRepository(ms mstore.MStorer) *RemoteRepository
func (*RemoteRepository) Add ¶
func (rr *RemoteRepository) Add(t *task.Task) error
func (*RemoteRepository) CleanUp ¶
func (rr *RemoteRepository) CleanUp() error
Cleanup removes older versions of tasks
func (*RemoteRepository) FindAll ¶
func (rr *RemoteRepository) FindAll(folder string) ([]*task.Task, error)
func (*RemoteRepository) Remove ¶
func (rr *RemoteRepository) Remove(tasks []*task.Task) error
func (*RemoteRepository) Update ¶
func (rr *RemoteRepository) Update(t *task.Task) error
type Sqlite ¶
type Sqlite struct {
// contains filtered or unexported fields
}
Sqlite is an sqlite implementation of LocalRepository
func NewSqlite ¶
func NewSqlite(conf *SqliteConfig) (*Sqlite, error)