server

package
v0.0.0-...-e688aee Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2017 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ShuttingDown bool

ShuttingDown variable is used to note that the server is about to shut down. It is false by default, and set to true when a shutdown signal is received.

Functions

func BatchHandler

func BatchHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration)

func CreateBatchHandler

func CreateBatchHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration)

func DecrCounter

func DecrCounter(addr *uint64)

DecrCounter decrements a given counter by 1

func IncrCounter

func IncrCounter(addr *uint64)

IncrCounter increments a given counter by 1

func InitializeServer

func InitializeServer(sc *core.ServerConfiguration, listen string, port string)

InitializeServer creates a new http server to handle image processing requests

func InitializeStatusServer

func InitializeStatusServer(listen string, port string)

InitializeStatusServer starts a web server that can be used to monitor the health of the application. It returns a response with status code 200 if the system is healthy.

func NewImageHandler

func NewImageHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration)

NewImageHandler handles posting new images

func NewRouter

func NewRouter(sc *core.ServerConfiguration) *mux.Router

NewRouter creates a mux.Router for use in code or in tests

func ResizeHandler

func ResizeHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration)

ResizeHandler asumes the original image is either stores locally or on the remote server it returns the processed image in given dimension and format. When an image is requested more than once, only one will do the processing, and both requests will return the same output

func ResizeManyHandler

func ResizeManyHandler(w http.ResponseWriter, req *http.Request, sc *core.ServerConfiguration)

ResizeManyHandler asumes the original image is either stores locally or on the remote server It returns status code 200 and no content A listing will be requested to the uploader to determine what images are missing, and only Images not already processed will be generated and uploaded

Types

type ServerStatus

type ServerStatus struct{}

ServerStatus implements the http.Handler interface

func (*ServerStatus) ServeHTTP

func (f *ServerStatus) ServeHTTP(w http.ResponseWriter, req *http.Request)

It returns a status code 501 when the server is shutting down, or when a processor is not detected. Details are provided in the body of the request.

type Stats

type Stats struct {
	Current     uint64 `json:"current"`
	TotalCount  uint64 `json:"total_count"`
	FailedCount uint64 `json:"failed_count"`
}

Stats store atomic values

type Status

type Status struct {
	Version string `json:"version"`
	Message string `json:"message"`
	Posting *Stats `json:"posting"`
}

Status keeps the current state of the server

Jump to

Keyboard shortcuts

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