eather

package module
v0.4.0 Latest Latest
Warning

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

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

README

EATHER Project

Overview

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(dirs []string)

LoadModules will load all modules inside modules directory

func RegisterRoutes added in v0.3.0

func RegisterRoutes(corsOpts *cors.Cors)

RegisterRoutes - listen for routes

func SendJSONResponse added in v0.3.0

func SendJSONResponse(w http.ResponseWriter, r Response)

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

func Start

func Start(conf ConfigInterface)

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 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

func (*Config) AddModuleDirs added in v0.3.2

func (c *Config) AddModuleDirs(dir ...string)

AddModuleDirs will replace moduleDirs by new

func (*Config) GetCorsOpts added in v0.4.0

func (c *Config) GetCorsOpts() *cors.Cors

GetCorsOpts returns cor config

func (*Config) GetCrons added in v0.3.2

func (c *Config) GetCrons() CronList

GetCrons returns slice of Cron

func (*Config) GetModuleDirs added in v0.3.2

func (c *Config) GetModuleDirs() []string

GetModuleDirs returns directories of modules

func (*Config) GetServerConf added in v0.4.0

func (c *Config) GetServerConf() *http.Server

GetServerConf returns server configuration

func (*Config) SetCorsOpts added in v0.4.0

func (c *Config) SetCorsOpts(cors *cors.Cors)

SetCorsOpts will set cors for application

func (*Config) SetServerConfig added in v0.4.0

func (c *Config) SetServerConfig(s *http.Server)

SetServerConfig will set server configuration

type ConfigInterface added in v0.4.0

type ConfigInterface interface {
	AddCron(spec Spec, cmd Cmd)
	AddModuleDirs(dir ...string)
	SetCorsOpts(cors *cors.Cors)
	SetServerConfig(*http.Server)

	GetCrons() CronList
	GetModuleDirs() []string
	GetCorsOpts() *cors.Cors
	GetServerConf() *http.Server
}

ConfigInterface interface of config

func GetConfig added in v0.3.2

func GetConfig() ConfigInterface

GetConfig will return default config settings

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 DataResponse added in v0.3.1

type DataResponse map[string]interface{}

DataResponse set DataResponse type

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 DatabaseCreatedAt added in v0.4.0

type DatabaseCreatedAt struct {
	CreatedAt time.Time `jsonapi:"attr,created_at"`
}

DatabaseCreatedAt set default created_at column

type DatabaseDeletedAt added in v0.4.0

type DatabaseDeletedAt struct {
	DeletedAt *time.Time `sql:"index" jsonapi:"attr,deleted_at"`
}

DatabaseDeletedAt set default deleted_at column

type DatabaseID added in v0.4.0

type DatabaseID struct {
	ID uuid.UUID `gorm:"primary_key"`
}

DatabaseID set default ID column

func (*DatabaseID) BeforeCreate added in v0.4.0

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

BeforeCreate will set a UUID rather than numeric ID.

type DatabaseUpdatedAt added in v0.4.0

type DatabaseUpdatedAt struct {
	UpdatedAt time.Time `jsonapi:"attr,updated_at"`
}

DatabaseUpdatedAt set default updated_at column

type Event added in v0.4.0

type Event struct {
	Name  string `json:"name"`
	Fires []Fire `json:"-"`
}

Event structure

type EventCollection added in v0.3.0

type EventCollection map[string]Event

EventCollection is definition of events collection

type EventFunc added in v0.4.0

type EventFunc func(data ...interface{})

EventFunc type of events func

type Eventable added in v0.4.0

type Eventable interface {
	GetEventFuncs() []Fire
}

Eventable interface for modules that are with events add this func to module to enable events

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 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 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 Fire added in v0.4.0

type Fire struct {
	Call string
	Func EventFunc
}

Fire struct of Fires

type Installable added in v0.4.0

type Installable interface {
	Install()
}

Installable interface for modules that are with func Install add this func to run install func during installation of module

type ModelBase added in v0.4.0

ModelBase contains common columns for all tables.

type Module added in v0.3.0

type Module interface{}

Module interface

type ModuleVersion added in v0.3.0

type ModuleVersion struct {
	ID uint `gorm:"primary_key"`
	DatabaseCreatedAt
	DatabaseUpdatedAt
	DatabaseDeletedAt
	Name    string
	Version string
}

ModuleVersion struct - structure of moduleVersion in database

type ModuleXML added in v0.4.0

type ModuleXML types.ModuleXML

Module of type ModuleXML

func (ModuleXML) GetVersion added in v0.4.0

func (m ModuleXML) GetVersion() string

GetVersion - load version from database

func (ModuleXML) UpdateVersion added in v0.4.0

func (m ModuleXML) UpdateVersion()

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

type Registry added in v0.3.0

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

Registry struct - collection for registry

func (*Registry) Add added in v0.3.0

func (r *Registry) Add(object 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) Module

Get module from registry by name

func (*Registry) GetCollection added in v0.4.0

func (r *Registry) GetCollection() RegistryCollection

GetCollection returns collection of all modules

func (*Registry) Remove added in v0.3.0

func (r *Registry) Remove(name string)

Remove module from collection

type RegistryCollection added in v0.4.0

type RegistryCollection map[string]Module

RegistryCollection map of all modules in registry

type RegistryInterface added in v0.3.0

type RegistryInterface interface {
	Get(name string) Module
	GetCollection() RegistryCollection
	Add(object 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 struct {
	Status     bool
	Message    string
	Data       DataResponse
	StatusCode int
}

Response struct - customize response for routes

type Routable added in v0.4.0

type Routable interface {
	MapRoutes()
}

Routable interface for modules that are with func Routable add this func to map routes for module

type Routes added in v0.3.0

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

Routes struct - collection of routes

type Spec added in v0.3.0

type Spec string

Spec for specification when cron should be running

type Upgradable added in v0.4.0

type Upgradable interface {
	Upgrade(version string)
}

Upgradable interface for modules that are with func Upgrade add this func to run Upgrade after upgrading module version

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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