governor

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 5, 2019 License: MPL-2.0 Imports: 17 Imported by: 0

README

governor

yet another microservice framework

confirm dev setup
  • make devup will start a local docker network
  • make dev will start a local golang server instance
  • curl localhost:8080/api/healthz/ping should return back Pong and log Ping on the server
  • curl localhost:8080/api/healthz/check should return back a timestamp and no errors
  • make devdown will bring down the docker network
helpful tools
  • docker ps will show all currently running containers

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Must

func Must(err error)

Must ensures that the operation must succeed

Types

type Config

type Config struct {
	Appname       string
	Version       string
	VersionHash   string
	LogLevel      int
	Port          string
	BaseURL       string
	PublicDir     string
	TemplateDir   string
	MaxReqSize    string
	FrontendProxy []string
	Origins       []string
	RouteRewrite  map[string]string
	// contains filtered or unexported fields
}

Config is the server configuration

func NewConfig

func NewConfig(confFilenameDefault string, versionhash string) (Config, error)

NewConfig creates a new server configuration

func (*Config) Conf

func (c *Config) Conf() *viper.Viper

Conf returns the config instance

func (*Config) Init

func (c *Config) Init() error

Init reads in the config

func (*Config) IsDebug

func (c *Config) IsDebug() bool

IsDebug returns if the configuration is in debug mode

type Error

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

Error is an error container

func NewError

func NewError(origin string, message string, code int, status int) *Error

NewError creates a new custom Error

func NewErrorUser

func NewErrorUser(origin string, message string, code int, status int) *Error

NewErrorUser creates a new custom Error

func NewErrorWarn

func NewErrorWarn(origin string, message string, code int, status int) *Error

NewErrorWarn creates a new custom Error

func (*Error) AddTrace

func (e *Error) AddTrace(module string)

AddTrace adds the current caller to the call stack of the error

func (*Error) Code

func (e *Error) Code() int

Code returns the error code

func (*Error) Error

func (e *Error) Error() string

func (*Error) IsErrorUser

func (e *Error) IsErrorUser() bool

IsErrorUser returns if the error is a user error

func (*Error) Level

func (e *Error) Level() int

Level returns the severity of the error

func (*Error) Message

func (e *Error) Message() string

Message returns the error message

func (*Error) Origin

func (e *Error) Origin() string

Origin returns the origin of the error message

func (*Error) SetErrorUser

func (e *Error) SetErrorUser()

SetErrorUser makes the error a user error

func (*Error) Source

func (e *Error) Source() string

Source returns the source of the error message

func (*Error) Status

func (e *Error) Status() int

Status returns the http status

type Logger

type Logger interface {
	Debug(msg, module, event string, code int, data map[string]string)
	Info(msg, module, event string, code int, data map[string]string)
	Warn(msg, module, event string, code int, data map[string]string)
	Error(msg, module, event string, code int, data map[string]string)
	Fatal(msg, module, event string, code int, data map[string]string)
}

func NewLogger

func NewLogger(c Config) Logger

type ReqSetupPost

type ReqSetupPost struct {
	Username  string `json:"username"`
	Password  string `json:"password"`
	Email     string `json:"email"`
	Firstname string `json:"first_name"`
	Lastname  string `json:"last_name"`
	Orgname   string `json:"orgname"`
}

ReqSetupPost is the http post request for the setup

type Server

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

Server is an http gateway

func New

func New(config Config, l Logger) (*Server, error)

New creates a new Server

func (*Server) MountRoot

func (s *Server) MountRoot(path string, r Service, m ...echo.MiddlewareFunc) error

MountRoot mounts a service at the root path

func (*Server) MountRoute

func (s *Server) MountRoute(path string, r Service, m ...echo.MiddlewareFunc) error

MountRoute mounts a service

func (*Server) Start

func (s *Server) Start() error

Start starts the server at the specified port

type Service

type Service interface {
	Mount(c Config, l Logger, r *echo.Group) error
	Health() *Error
	Setup(c Config, l Logger, rsetup ReqSetupPost) *Error
}

Service is an interface for services

Directories

Path Synopsis
cmd
gov
service
conf/model
Code generated by go generate.
Code generated by go generate.
courier/model
Code generated by go generate.
Code generated by go generate.
db
profile/model
Code generated by go generate.
Code generated by go generate.
user/model
Code generated by go generate.
Code generated by go generate.
user/role/model
Code generated by go generate.
Code generated by go generate.
util
uid

Jump to

Keyboard shortcuts

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