poller

package module
v1.0.0-alpha-9095eaa31... Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

poller

Golang library for data polling.

About The Project

Poller - small library, that contains basic logic for data polling mechanisms. One of the common library use cases is implementation of outbox pattern.

Features:

  • laconic api
  • context package support
  • concurrency limit

Usage

process := poller.New(3*time.Second, 2, 2, 2, func(ctx context.Context, limit int) ([]poller.Task, bool) {
	return fetchTasksFromDatabase(limit)
})
process.Start()

License

Poller is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.

Contact

  • Email: cherkashin.evgeny.viktorovich@gmail.com
  • Telegram: @evgeny_cherkashin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Poller

type Poller struct {
	// contains filtered or unexported fields
}

func New

func New(
	period time.Duration,
	size int,
	threshold int,
	concurrency int,
	next func(ctx context.Context, limit int) (tasks []Task, hasMore bool),
) (poller *Poller)

func (*Poller) Done

func (p *Poller) Done() <-chan struct{}

func (*Poller) Start

func (p *Poller) Start()

func (*Poller) StartContext

func (p *Poller) StartContext(ctx context.Context)

func (*Poller) Stop

func (p *Poller) Stop()

func (*Poller) StopContext

func (p *Poller) StopContext(ctx context.Context)

type Task

type Task interface {
	Run(ctx context.Context)
}

Jump to

Keyboard shortcuts

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