tmpdocker

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Dec 31, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

README

Description

use docker service to auto scale backend service

- handler: "tmpdocker"
  # required
  service_name: "demo-service"
  # if no request after 20m will scale the service to 0 , if have request will scale to 1
  freeze_timeout: "20m"
- handler: "reverse_proxy"
  # set the server docker service backend
  upstreams: [{ dial: "demo-service" }]

Build

cd cmd/caddy
go build
./caddy list-modules | grep docker
# you will see `http.handlers.tmpdocker` plugin

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TmpDocker

type TmpDocker struct {
	ServiceName   string         `json:"service_name,omitempty"`
	FreezeTimeout caddy.Duration `json:"freeze_timeout,omitempty"`
	DockerHost    string         `json:"docker_host,omitempty"`
	// contains filtered or unexported fields
}

TmpDocker is a middleware which can rewrite HTTP requests.

func (TmpDocker) CaddyModule

func (TmpDocker) CaddyModule() caddy.ModuleInfo

CaddyModule returns the Caddy module information.

func (TmpDocker) GetRunning

func (tmpd TmpDocker) GetRunning(serviceID string) (count int, err error)

GetRunning node length

func (TmpDocker) GetTmpService

func (tmpd TmpDocker) GetTmpService() (*TmpService, error)

GetTmpService v

func (*TmpDocker) Provision

func (tmpd *TmpDocker) Provision(ctx caddy.Context) error

Provision sets up tmpd.

func (TmpDocker) ScaleDockerService

func (tmpd TmpDocker) ScaleDockerService() error

ScaleDockerService use docker

func (TmpDocker) ServeHTTP

func (tmpd TmpDocker) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (TmpDocker) StopDockerService

func (tmpd TmpDocker) StopDockerService() error

StopDockerService use docker

func (*TmpDocker) Validate

func (tmpd *TmpDocker) Validate() (err error)

Validate validates tmpd.

type TmpService

type TmpService struct {
	ID          string
	Replicas    uint64
	ServiceSpec swarm.ServiceSpec
	Version     swarm.Version
}

TmpService v

Directories

Path Synopsis
cmd
caddy command
Package main is the entry point of the Caddy application.
Package main is the entry point of the Caddy application.

Jump to

Keyboard shortcuts

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