worker

package
v0.0.0-...-67d7764 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2018 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package worker implements various workers to process requests sent by the user

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type NameWorker

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

NameWorker processes name related requests By first checking database and storage before making remote calls for information.

func NewNameWorker

func NewNameWorker() (*NameWorker, error)

NewNameWorker initializes a worker with new storage and database based on configuration variables specified. The worker can perform name-related operations using Blockstack API and persist any relevant data into database and storage.

func (*NameWorker) AddNames

func (nw *NameWorker) AddNames(n map[string]map[string]bool) (dbErr error, stgErr error)

AddNames persists the set of names for each namespace into the database and storage.

func (*NameWorker) FetchAndAddNames

func (nw *NameWorker) FetchAndAddNames() (names map[string]map[string]bool, err error)

FetchAndAddNames attempts to query the remote API for the set of names for each namespace at the current date. If successful, the results are persisted to underlying database and storage.

func (*NameWorker) FetchNames

func (nw *NameWorker) FetchNames() (map[string]map[string]bool, error)

func (*NameWorker) FetchNamespaceNames

func (nw *NameWorker) FetchNamespaceNames(namespace string, out chan<- NamespaceNames, errCh chan<- error, wg *sync.WaitGroup)

fetch asynchronously inserts results to database

func (*NameWorker) GetNames

func (nw *NameWorker) GetNames() (map[string]map[string]bool, error)

GetNames returns the set of all names at current day

func (*NameWorker) GetNamesAt

func (nw *NameWorker) GetNamesAt(date time.Time) (map[string]map[string]bool, error)

GetNamesAt attempts to find and return the set of names for each namespace at the given date

func (*NameWorker) RetrieveNames

func (nw *NameWorker) RetrieveNames() (result map[string]map[string]bool, err error)

RetrieveNames attempts to return the set of names at current date. If the names don't exist in database or storage, they are fetch from remote API.

func (*NameWorker) RetrieveNewNames

func (nw *NameWorker) RetrieveNewNames(since time.Time) (map[string]map[string]bool, error)

RetrieveNewNames attempts to compare the latest set of names for each namespace to the set found at the provided time. If no previous data exists at the specified time, an error is returned. Otherwise a set of new names is returned.

func (*NameWorker) Shutdown

func (nw *NameWorker) Shutdown() error

Jump to

Keyboard shortcuts

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