server

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2018 License: Apache-2.0 Imports: 51 Imported by: 4

Documentation

Index

Constants

View Source
const (

	//StateUpdateEventName used in etcd path
	StateUpdateEventName = "state_update"
	//MonitoringUpdateEventName used in etcd path
	MonitoringUpdateEventName = "monitoring_update"
)
View Source
const (
	SyncWatchRevisionPrefix = "/gohan/watch/revision"
)

SyncWatchRevisionPrefix

Variables

This section is empty.

Functions

func GetSchema

func GetSchema(s *schema.Schema, authorization schema.Authorization) (result *schema.Resource, err error)

GetSchema returns the schema filtered and trimmed for a specific user or nil when the user shouldn't see it at all

func MapNamespacesRoutes

func MapNamespacesRoutes(route martini.Router)

MapNamespacesRoutes maps routes for all namespaces

func MapRouteBySchema

func MapRouteBySchema(server *Server, dataStore db.DB, s *schema.Schema)

MapRouteBySchema setup api route by schema

func MapRouteBySchemas

func MapRouteBySchemas(server *Server, dataStore db.DB)

MapRouteBySchemas setup route for all loaded schema

func Resync

func Resync(dbConn db.DB, sync sync.Sync) (err error)

Resync performs resync

func RunServer

func RunServer(configFile string)

RunServer runs gohan api server

Types

type DbSyncWrapper

type DbSyncWrapper struct {
	db.DB
}

DbSyncWrapper wraps db.DB so it logs events in database on every transaction.

func (*DbSyncWrapper) Begin

func (sw *DbSyncWrapper) Begin() (transaction.Transaction, error)

Begin wraps transaction object with sync

func (*DbSyncWrapper) BeginTx

BeginTx wraps transaction object with sync

type Server

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

Server is a struct for GohanAPIServer

func NewServer

func NewServer(configFile string) (*Server, error)

NewServer returns new GohanAPIServer

func (*Server) Address

func (server *Server) Address() string

Address returns server address.

func (*Server) GetSync

func (server *Server) GetSync() sync.Sync

GetSync returns server sync.

func (*Server) NewEnvironmentForPath

func (server *Server) NewEnvironmentForPath(name string, path string) (env extension.Environment, err error)

NewEnvironmentForPath creates an extension environment and loads extensions for path

func (*Server) Queue

func (server *Server) Queue() *job.Queue

Queue returns servers build-in queue

func (*Server) Router

func (server *Server) Router() http.Handler

Router returns http handler

func (*Server) SetRunning

func (server *Server) SetRunning(running bool)

SetRunning sets server running status.

func (*Server) Start

func (server *Server) Start() (err error)

Start starts GohanAPIServer

func (*Server) Stop

func (server *Server) Stop()

Stop stops GohanAPIServer

type StateWatcher

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

StateWatcher handles Gohan's state update events from the sync layer. Resources configured with `state_versioning: true` receives monitoring_update and state_update events from StateWatcher when it detects updates in the sync layer.

func NewStateWatcher

func NewStateWatcher(sync gohan_sync.Sync, db db.DB, identity middleware.IdentityService) *StateWatcher

NewStateWatcher creates a new instance of StateWatcher.

func NewStateWatcherFromServer

func NewStateWatcherFromServer(server *Server) *StateWatcher

NewStateWatcherFromServer is a constructor for StateWatcher

func (*StateWatcher) MonitoringUpdate

func (watcher *StateWatcher) MonitoringUpdate(event *gohan_sync.Event) error

MonitoringUpdate updates the state in the db based on the sync event todo: make private once tests are fixed

func (*StateWatcher) Run

func (watcher *StateWatcher) Run(ctx context.Context) error

Run starts the main loop of the watcher. This method blocks until canceled by the ctx. Errors are logged, but do not interrupt the loop.

func (*StateWatcher) StateUpdate

func (watcher *StateWatcher) StateUpdate(event *gohan_sync.Event) error

StateUpdate updates the state in the db based on the sync event todo: make private once tests are fixed

type SyncWatcher

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

SyncWatcher runs extensions when it detects a change on the sync. The watcher implements a load balancing mechanism that uses entries on the sync.

func NewSyncWatcher

func NewSyncWatcher(sync gohan_sync.Sync, keys []string, events []string, extensions map[string]extension.Environment) *SyncWatcher

NewSyncWatcher creates a new instance of syncWatcher

func NewSyncWatcherFromServer

func NewSyncWatcherFromServer(server *Server) *SyncWatcher

NewSyncWatcherFromServer creates a new instance of syncWatcher from server

func (*SyncWatcher) Run

func (watcher *SyncWatcher) Run(ctx context.Context) error

Run starts the main loop of the watcher. This method blocks until the ctx is canceled by the caller

type SyncWriter

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

SyncWriter copies data from the RDBMS to the sync layer. All changes happens in the RDBMS will be synchronized into the sync layer by SyncWriter. SyncWriter gets items to sync from the event table.

func NewSyncWriter

func NewSyncWriter(sync gohan_sync.Sync, db db.DB) *SyncWriter

NewSyncWriter creates a new instance of SyncWriter.

func NewSyncWriterFromServer

func NewSyncWriterFromServer(server *Server) *SyncWriter

NewSyncWriterFromServer is a helper method for test. Should be removes in the future.

func (*SyncWriter) Run

func (writer *SyncWriter) Run(ctx context.Context) error

Run starts a loop to keep running Sync(). This method blocks until the ctx is canceled.

func (*SyncWriter) Sync

func (writer *SyncWriter) Sync() (synced int, err error)

Sync runs a synchronization iteration, which executes requests in the event table.

Directories

Path Synopsis
Package mock_middleware is a generated GoMock package.
Package mock_middleware is a generated GoMock package.

Jump to

Keyboard shortcuts

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