sql

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultEnabled defines a state for default config
	DefaultEnabled = false

	// DefaultDatabaseURI defines the default contact point towards the mysql server instance
	DefaultDatabaseURI = "/tmp/asparagus.db"

	// DefaultDriver defines a default driver for the sql package
	DefaultDriver = "sqlite3"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Enabled        bool   `toml:"enabled"`
	DatabaseURI    string `toml:"uri"`
	DatabaseDriver string `toml:"driver"`
}

Config represents a configuration for a HTTP service.

func NewConfig

func NewConfig() Config

NewConfig returns a new Config with default settings.

type Connection

type Connection struct {
	Config    Config
	SQL       *sql.DB
	WatchChan *time.Ticker
	Cancel    chan struct{}
}

Connection defines a wrapper for the actual etcd connection

func NewConnection

func NewConnection(config Config) *Connection

NewConnection creates a new etcd connection

func (*Connection) Close

func (c *Connection) Close() error

func (*Connection) Connect

func (c *Connection) Connect() error

Connect connects the etcd target

func (*Connection) ReadAll

func (c *Connection) ReadAll() (tasks []provider.Task, err error)

ReadAll reads all cronjobs inside a directory

func (*Connection) ReadTask

func (c *Connection) ReadTask(key string, task *provider.Task) error

ReadTask reads a task from etcd

func (*Connection) WatchTasks

func (c *Connection) WatchTasks(cb func(t provider.Task))

WatchTasks looks for new keys inside etcd

func (*Connection) WriteTask

func (c *Connection) WriteTask(t *provider.Task) error

WriteTask persists a task inside etcd

type SourceProvider

type SourceProvider struct {
	Config     Config
	Connection *Connection
	TaskFlow   chan provider.Task
	QuitChan   chan bool
}

SourceProvider creates a new src provider

func NewSourceProvider

func NewSourceProvider(config Config) *SourceProvider

NewSourceProvider creates a new src provider

func (SourceProvider) OnTaskUpdate

func (p SourceProvider) OnTaskUpdate(fn func(*provider.Task) error)

OnTaskUpdate runs when a task gets updated

func (*SourceProvider) Read

func (p *SourceProvider) Read() (err error)

Read reads from FS

func (SourceProvider) Stop

func (p SourceProvider) Stop() error

Stop quits reading tasks

func (SourceProvider) String

func (p SourceProvider) String() string

String returns the Providers identity

func (SourceProvider) TaskDone

func (p SourceProvider) TaskDone(t *provider.Task) error

TaskDone will be executed when a task is done

func (SourceProvider) TaskError

func (p SourceProvider) TaskError(t *provider.Task, err error) error

TaskError will be called when an error occured

func (SourceProvider) TaskStarted

func (p SourceProvider) TaskStarted(t *provider.Task) error

TaskStarted will be executed when a task is started

Jump to

Keyboard shortcuts

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