eather

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2019 License: MIT Imports: 22 Imported by: 0

README

Eather Project

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache added in v0.3.0

func GetCache() *bigcache.BigCache

GetCache to get cache instance

func GetRouter added in v0.3.0

func GetRouter() *mux.Router

GetRouter - return route collection

func InitVersion added in v0.3.0

func InitVersion()

InitVersion - initialize version with automigration

func LoadModules added in v0.3.0

func LoadModules()

LoadModules will load all modules inside modulesDir directory

func RegisterRoutes added in v0.3.0

func RegisterRoutes()

RegisterRoutes - listen for routes

func SendJSONResponse added in v0.3.0

func SendJSONResponse(w http.ResponseWriter, r EatherResponse)

SendJSONResponse will set type to application/json and send to response

func Start

func Start(conf *Config)

Start eather application initialize http server and load all modules

func StartCrons added in v0.3.0

func StartCrons(cronList []Cron)

StartCrons will start crons in background

Types

type Base added in v0.3.0

type Base struct {
	ID        uuid.UUID `gorm:"primary_key"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time `sql:"index"`
}

Base contains common columns for all tables.

func (*Base) BeforeCreate added in v0.3.0

func (base *Base) BeforeCreate(scope *gorm.Scope) error

BeforeCreate will set a UUID rather than numeric ID.

type Cmd added in v0.3.0

type Cmd func()

Cmd function of cron

type Config added in v0.3.0

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

Config structure of config for Eather

func (*Config) AddCron added in v0.3.0

func (c *Config) AddCron(spec Spec, cmd Cmd)

AddCron will append new cron to the config

type Cron added in v0.3.0

type Cron struct {
	Spec Spec
	Cmd  Cmd
}

Cron structure

type CronList added in v0.3.0

type CronList []Cron

CronList structure of list of crons

type Database added in v0.3.0

type Database struct {
	*gorm.DB
}

Database struct - structure of database

func GetDb added in v0.3.0

func GetDb() *Database

GetDb - get instance of database

type EatherResponse added in v0.3.0

type EatherResponse struct {
	Status     bool
	Message    string
	Data       Response
	StatusCode int
}

EatherResponse struct - customize response for routes

type EventCollection added in v0.3.0

type EventCollection map[string]event

EventCollection is definition of events collection

type Events added in v0.3.0

type Events struct {
	Collection EventCollection
}

Events struct - collection of events

func (*Events) Add added in v0.3.0

func (r *Events) Add(name string, f types.EventFunc, call string)

Add event to the collection

func (*Events) Emmit added in v0.3.0

func (r *Events) Emmit(name string, data ...interface{})

Emmit the event from the collection data will be passed to the event func

func (*Events) GetCollection added in v0.3.0

func (r *Events) GetCollection() EventCollection

GetCollection will return collection of events

func (*Events) Remove added in v0.3.0

func (r *Events) Remove(name string)

Remove the event from the collection

type EventsInterface added in v0.3.0

type EventsInterface interface {
	Emmit(name string, data ...interface{})
	Add(name string, f types.EventFunc, call string)
	Remove(name string)
	GetCollection() EventCollection
}

EventsInterface interface of events

func GetEvents added in v0.3.0

func GetEvents() EventsInterface

GetEvents - get collection of all registered events

type FiresCollection added in v0.3.0

type FiresCollection map[string]types.EventFunc

FiresCollection is definition of fires collection

type Module added in v0.3.0

type Module types.ModuleXML

Module of type ModuleXML

func (Module) GetVersion added in v0.3.0

func (m Module) GetVersion() string

GetVersion - load version from database

func (Module) UpdateVersion added in v0.3.0

func (m Module) UpdateVersion()

UpdateVersion - set the new version of the module to the database

type ModuleVersion added in v0.3.0

type ModuleVersion struct {
	gorm.Model
	Name    string
	Version string
}

ModuleVersion struct - structure of moduleVersion in database

type Registry added in v0.3.0

type Registry struct {
	Collection map[string]types.Module
}

Registry struct - collection for registry

func (*Registry) Add added in v0.3.0

func (r *Registry) Add(object types.Module, name string)

Add module to the registry object

func (*Registry) Contains added in v0.3.0

func (r *Registry) Contains(name string) bool

Contains check if module is already in registry

func (*Registry) Get added in v0.3.0

func (r *Registry) Get(name string) types.Module

Get module from registry by name

func (*Registry) Remove added in v0.3.0

func (r *Registry) Remove(name string)

Remove module from collection

type RegistryInterface added in v0.3.0

type RegistryInterface interface {
	Get(name string) types.Module
	Add(object types.Module, name string)
	Contains(name string) bool
	Remove(name string)
}

RegistryInterface - interface for a registry

func GetRegistry added in v0.3.0

func GetRegistry() RegistryInterface

GetRegistry load registry collection

type Response added in v0.3.0

type Response map[string]interface{}

Response set response type

type Routes added in v0.3.0

type Routes struct {
	Collection map[string]func(w http.ResponseWriter, r *http.Request) EatherResponse
}

Routes struct - collection of routes

type Spec added in v0.3.0

type Spec string

Spec for specification when cron should be running

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

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