worker

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package worker synchronizes data between API and DB.

It queries the API at a specified interval and merges the results into the DB.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DocTransformer

type DocTransformer[T any] interface {
	Transform(data transform.APIData, errFunc func(error)) *db.DocsProvider[T]
}

DocTransformer provides a means of converting API data into structs ready for passing to the MongoDB driver.

type Worker

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

Worker coordinates communication between API and DB.

func New

func New(api *client.Client, db *db.Client, logger *log.Logger) *Worker

New creates a new Worker instance.

func (*Worker) Run

func (w *Worker) Run(interval time.Duration, stop <-chan struct{})

Run schedules a new sync job at the specified interval. It is blocking.

Jump to

Keyboard shortcuts

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