mona

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

README

mona

An automation system to use with dedo.

Purpose

mona was designed with real business cases in mind. The dedo library provides a toolchain for warehousing data, and pafi provides a nice interface to it, but in order to achieve a truly effective data warehousing project, you can't be loading in files manually all the time. mona provides the automation side of this warehousing suite by allowing users to define their own data retrieval processes and run those processes on a schedule in the background.

Usage

The usage of mona is similar to a web server. You define your own processes according to an interface, register those implementations with the daemon, and then run it.

Note that this example doesn't contain a lot of the code that would be required. See examples for more detailed implementations.

package main

...

func main() {
    var d mona.Daemon

    t1 := MyFirstTarget{
        Username: "sbeve",
        Password: "sbeve",
    }
    t2 := MySecondTarget{
        SomeOtherParameter: "information",
        AndAnotherOne:      "more information",
    }

    d.Register(t1)
    d.Register(t2)

    d.Run()
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandlerFunc

func NewHandlerFunc(t Target) func()

NewHandlerFunc creates a new handler function based on the target in the Handler struct. This function calls the target and loads the data into the database through the dedo API.

Types

type Daemon

type Daemon struct {
	Targets []Target
}

Daemon is the primary API that the user uses to add targets and run call cycles on a continuous basis.

func (*Daemon) Register

func (d *Daemon) Register(t Target)

Register adds a Target implementation to the daemon's target registry.

func (Daemon) Run

func (d Daemon) Run()

Run adds tasks according to all registered Target implementations and starts the blocking call to the gocron API.

type Directive

type Directive struct {
	Prefix        string
	Configuration dedo.Configuration
	Warehouse     dedo.Warehouse
}

Directive defines where data from a target should go according to a provided dedo configuration and database.

type Schedule

type Schedule struct {
	Type   ScheduleType
	Window uint64
}

Schedule defines a call cycle schedule configuration to be consumed by the gocron API, returned by Target.Schedule.

type ScheduleType

type ScheduleType int

ScheduleType abstracts the available window type constants for call cycle scheduling.

const (
	Minute ScheduleType = 0
	Hour   ScheduleType = 1
	Day    ScheduleType = 2
	Week   ScheduleType = 3
)

Minute, Hour, Day, and Week constants are used by the daemon to determine how to schedule calls with the gocron API.

type Target

type Target interface {
	Name() string
	Schedule() (*Schedule, error)
	Directive() (*Directive, error)
	Call() (*dedo.Shipment, error)
}

Target is the interface that user-defined data retrieval processes must abide by in order to be successfully consumed by the daemon.

Jump to

Keyboard shortcuts

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