server

package
v0.0.0-...-526e170 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2017 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvLogLevel = "log_level"
	EnvMQURL    = "mq_url"
	EnvDBURL    = "db_url"
	EnvPort     = "port" // be careful, Gin expects this variable to be "port"
	EnvAPIURL   = "api_url"
)

Variables

View Source
var ErrInternalServerError = errors.New("Something unexpected happened on the server")
View Source
var ErrNoSpecialHandlerFound = errors.New("Path not found")
View Source
var Version = "0.2.4"

Version of IronFunctions

Functions

func DefaultEnqueue

func DefaultEnqueue(ctx context.Context, mq models.MessageQueue, task *models.Task) (*models.Task, error)

func ToEnvName

func ToEnvName(envtype, name string) string

Types

type AppCreateListener

type AppCreateListener interface {
	// BeforeAppCreate called right before creating App in the database
	BeforeAppCreate(ctx context.Context, app *models.App) error
	// AfterAppCreate called after creating App in the database
	AfterAppCreate(ctx context.Context, app *models.App) error
}

type AppDeleteListener

type AppDeleteListener interface {
	// BeforeAppDelete called right before deleting App in the database
	BeforeAppDelete(ctx context.Context, app *models.App) error
	// AfterAppDelete called after deleting App in the database
	AfterAppDelete(ctx context.Context, app *models.App) error
}

type AppUpdateListener

type AppUpdateListener interface {
	// BeforeAppUpdate called right before updating App in the database
	BeforeAppUpdate(ctx context.Context, app *models.App) error
	// AfterAppUpdate called after updating App in the database
	AfterAppUpdate(ctx context.Context, app *models.App) error
}

type Handle

type Handle func(http.ResponseWriter, *http.Request, Params)

type HandlerContext

type HandlerContext interface {
	// Context return the context object
	Context() context.Context

	// Request returns the underlying http.Request object
	Request() *http.Request

	// Response returns the http.ResponseWriter
	Response() http.ResponseWriter

	// Overwrite value in the context
	Set(key string, value interface{})
}

Each handler can modify the context here so when it gets passed along, it will use the new info.

type Param

type Param struct {
	Key   string
	Value string
}

type Params

type Params []Param

type RunnerListener

type RunnerListener interface {
	// BeforeDispatch called before a function run
	BeforeDispatch(ctx context.Context, route *models.Route) error
	// AfterDispatch called after a function run
	AfterDispatch(ctx context.Context, route *models.Route) error
}

type Server

type Server struct {
	Datastore models.Datastore
	Runner    *runner.Runner
	Router    *gin.Engine
	MQ        models.MessageQueue
	Enqueue   models.Enqueue
	// contains filtered or unexported fields
}

func New

func New(ctx context.Context, ds models.Datastore, mq models.MessageQueue, apiURL string, opts ...ServerOption) *Server

func (*Server) AddAppCreateListener

func (s *Server) AddAppCreateListener(listener AppCreateListener)

AddAppCreateListener adds a listener that will be notified on App created.

func (*Server) AddAppDeleteListener

func (s *Server) AddAppDeleteListener(listener AppDeleteListener)

AddAppDeleteListener adds a listener that will be notified on App deleted.

func (*Server) AddAppUpdateListener

func (s *Server) AddAppUpdateListener(listener AppUpdateListener)

AddAppUpdateListener adds a listener that will be notified on App updated.

func (*Server) AddRunnerListener

func (s *Server) AddRunnerListener(listener RunnerListener)

AddRunListeners adds a listener that will be fired before and after a function run.

func (*Server) AddSpecialHandler

func (s *Server) AddSpecialHandler(handler SpecialHandler)

func (*Server) FireAfterAppCreate

func (s *Server) FireAfterAppCreate(ctx context.Context, app *models.App) error

func (*Server) FireAfterAppDelete

func (s *Server) FireAfterAppDelete(ctx context.Context, app *models.App) error

func (*Server) FireAfterAppUpdate

func (s *Server) FireAfterAppUpdate(ctx context.Context, app *models.App) error

func (*Server) FireAfterDispatch

func (s *Server) FireAfterDispatch(ctx context.Context, route *models.Route) error

func (*Server) FireBeforeAppCreate

func (s *Server) FireBeforeAppCreate(ctx context.Context, app *models.App) error

func (*Server) FireBeforeAppDelete

func (s *Server) FireBeforeAppDelete(ctx context.Context, app *models.App) error

func (*Server) FireBeforeAppUpdate

func (s *Server) FireBeforeAppUpdate(ctx context.Context, app *models.App) error

func (*Server) FireBeforeDispatch

func (s *Server) FireBeforeDispatch(ctx context.Context, route *models.Route) error

func (*Server) Start

func (s *Server) Start(ctx context.Context)

func (*Server) UseSpecialHandlers

func (s *Server) UseSpecialHandlers(ctx context.Context, req *http.Request, resp http.ResponseWriter) (context.Context, error)

UseSpecialHandlers execute all special handlers

type ServerOption

type ServerOption func(*Server)

func EnableShutdownEndpoint

func EnableShutdownEndpoint(halt context.CancelFunc) ServerOption

type SpecialHandler

type SpecialHandler interface {
	Handle(c HandlerContext) error
}

type SpecialHandlerContext

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

func (*SpecialHandlerContext) Context

func (c *SpecialHandlerContext) Context() context.Context

func (*SpecialHandlerContext) Request

func (c *SpecialHandlerContext) Request() *http.Request

func (*SpecialHandlerContext) Response

func (*SpecialHandlerContext) Set

func (c *SpecialHandlerContext) Set(key string, value interface{})

Directories

Path Synopsis
internal
routecache
Package routecache is meant to assist in resolving the most used routes at an application.
Package routecache is meant to assist in resolving the most used routes at an application.

Jump to

Keyboard shortcuts

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