gaedispemu

package module
v0.4.1-0...-e20c92f Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2022 License: MIT Imports: 10 Imported by: 0

README

gae-dispatcher-emulator

Build Status codecov GoDoc

Unofficial Google App Engine Dispatcher Emulator

Description

gae-dispatcher-emulator is an unofficial emulator for Google App Engine dispatcher service. This works like a local reverse proxy, and it behave by dispatch.yaml or dispatch.xml.

Example:

$ (cd default; dev_appserver.py --port=8081 | tee -a dev.log) &
$ (cd mobile-backend; dev_appserver.py --port=8082 | tee -a dev.log) &
$ (cd static-backend; dev_appserver.py --port=8083 | tee -a dev.log) &
$ gae-dispatcher-emulator -c dispatch.yaml -s default:localhost:8081 -s mobile-frontend:localhost:8082 -s static-backend:localhost:8083

I suggest to use it with foreman to launch/shutdown services consistently.

Installation

go install github.com/karupanerura/gae-dispatcher-emulator/cmd/gae-dispatcher-emulator@v0.4.0

or you can install it from Github Releases.

Example:

curl -sfL -o ~/bin/gae-dispatcher-emulator https://github.com/karupanerura/gae-dispatcher-emulator/releases/download/v0.4.0/gae-dispatcher-emulator_darwin_amd64
chmod +x ~/bin/gae-dispatcher-emulator

Usage

Usage:
  gae-dispatcher-emulator [OPTIONS]

Application Options:
  -c, --config=	 dispatch.xml or dispatch.yaml
  -s, --service= service map (e.g. --service default:localhost:8081 --service admin:localhost:8082)
  -l, --listen=	 listening host:port (localhost:3000 is default) (default: localhost:3000)
  -v, --verbose	 verbose output for proxy request

Help Options:
  -h, --help	 Show this help message

Documentation

Index

Constants

View Source
const Version = "0.4.0"

Version is a current version of the package.

Variables

This section is empty.

Functions

func NewProxyHandler

func NewProxyHandler(dispatcher Dispatcher) http.Handler

NewProxyHandler creates a new proxy handler

func NewProxyHandlerWithReporter

func NewProxyHandlerWithReporter(dispatcher Dispatcher, errorReporter ErrorReporter) http.Handler

NewProxyHandlerWithReporter creates a new proxy handler with error reporter

Types

type Config

type Config struct {
	Rules []ConfigRule
}

Config is an abstruct configuration for GAE dispatch services.

func (Config) Len

func (c Config) Len() int

Len is length of the config.

type ConfigLoader

type ConfigLoader interface {
	LoadConfig() (*Config, error)
}

ConfigLoader is an interface to load dispatch.xml or dispatch.yaml

type ConfigRule

type ConfigRule struct {
	ServiceName string
	HostPathMatcher
}

ConfigRule is an abstruct dispatch rule for GAE dispatch services.

type Dispatcher

type Dispatcher interface {
	Dispatch(host, path string) *Service
}

Dispatcher is a service dispatcher

func NewDispatcher

func NewDispatcher(services map[string]*Service, config *Config) (Dispatcher, error)

NewDispatcher is a constructor of Dispatcher

type ErrorReporter

type ErrorReporter interface {
	ReportError(error)
}

ErrorReporter is error reporter interface for proxy handler

type ErrorReporterFunc

type ErrorReporterFunc func(error)

ErrorReporterFunc is function interface for ErrorReporter

func (ErrorReporterFunc) ReportError

func (r ErrorReporterFunc) ReportError(err error)

ReportError calls self as a function

type HostPathMatcher

type HostPathMatcher interface {
	MatchHostPath(host, path string) bool
}

HostPathMatcher is an abstruct matcher

func CompileHostPathMatcher

func CompileHostPathMatcher(pattern string) (HostPathMatcher, error)

CompileHostPathMatcher is constructor for HostPathMatcher

type Service

type Service struct {
	Name   string
	Origin *url.URL
}

Service is a GAE service and backend origin

type XMLConfigLoader

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

XMLConfigLoader is a config loader for dispatch.xml

func NewXMLConfigLoader

func NewXMLConfigLoader(filePath string) *XMLConfigLoader

NewXMLConfigLoader is constructor of XMLConfigLoader

func (*XMLConfigLoader) LoadConfig

func (l *XMLConfigLoader) LoadConfig() (*Config, error)

LoadConfig loads and parse the dispatch.xml

type YAMLConfigLoader

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

YAMLConfigLoader is a config loader for dispatch.yaml

func NewYAMLConfigLoader

func NewYAMLConfigLoader(filePath string) *YAMLConfigLoader

NewYAMLConfigLoader is constructor of YAMLConfigLoader

func (*YAMLConfigLoader) LoadConfig

func (l *YAMLConfigLoader) LoadConfig() (*Config, error)

LoadConfig loads and parse the dispatch.yaml

Directories

Path Synopsis
cmd
Usage:

Jump to

Keyboard shortcuts

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