lib

package
v0.2.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCache

func GetCache() *bigcache.BigCache

GetCache to get cache instance

func GetRouter

func GetRouter() *mux.Router

GetRouter - return route collection

func InitVersion

func InitVersion()

InitVersion - initialize version with automigration

func LoadModules

func LoadModules()

LoadModules will load all modules inside modulesDir directory

func RegisterRoutes

func RegisterRoutes()

RegisterRoutes - listen for routes

func SendJSONResponse

func SendJSONResponse(w http.ResponseWriter, r EatherResponse)

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

func StartCrons

func StartCrons(cronList []Cron)

StartCrons will start crons in background

Types

type Base

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

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

BeforeCreate will set a UUID rather than numeric ID.

type Cron added in v0.2.2

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

Cron structure

type Database

type Database struct {
	*gorm.DB
}

Database struct - structure of database

func GetDb

func GetDb() *Database

GetDb - get instance of database

type EatherResponse

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

EatherResponse struct - customize response for routes

type EventCollection

type EventCollection map[string]event

EventCollection is definition of events collection

type Events

type Events struct {
	Collection EventCollection
}

Events struct - collection of events

func (*Events) Add

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

Add event to the collection

func (*Events) Emmit

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

func (r *Events) GetCollection() EventCollection

GetCollection will return collection of events

func (*Events) Remove

func (r *Events) Remove(name string)

Remove the event from the collection

type EventsInterface

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

func GetEvents() EventsInterface

GetEvents - get collection of all registered events

type FiresCollection

type FiresCollection map[string]types.EventFunc

FiresCollection is definition of fires collection

type Module

type Module types.ModuleXML

Module of type ModuleXML

func (Module) GetVersion

func (m Module) GetVersion() string

GetVersion - load version from database

func (Module) UpdateVersion

func (m Module) UpdateVersion()

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

type ModuleVersion

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

ModuleVersion struct - structure of moduleVersion in database

type Registry

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

Registry struct - collection for registry

func (*Registry) Add

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

Add module to the registry object

func (*Registry) Contains

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

Contains check if module is already in registry

func (*Registry) Get

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

Get module from registry by name

func (*Registry) Remove

func (r *Registry) Remove(name string)

Remove module from collection

type RegistryInterface

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

func GetRegistry() RegistryInterface

GetRegistry load registry collection

type Response

type Response map[string]interface{}

Response set response type

type Routes

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

Routes struct - collection of routes

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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