rest

package module
v0.0.0-...-bb3b337 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: GPL-3.0 Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadRequestBody

func ReadRequestBody(req *http.Request) ([]byte, error)

ReadRequestBody ...

func Serve

func Serve(listen string, zk ZooNode, cors_options CorsOptions)

Serve ...

Types

type CorsOptions

type CorsOptions struct {
	Enabled        bool
	DebugEnabled   bool
	AllowedOrigins []string
}

type Get

type Get struct {
	Path   string   `json:"path"`
	State  string   `json:"state"`
	Error  string   `json:"error"`
	ZkStat *zk.Stat `json:"zkstat"`
	Data   []byte   `json:"data"`
}

Get ...

type GetJSON

type GetJSON struct {
	Path   string      `json:"path"`
	State  string      `json:"state"`
	Error  string      `json:"error"`
	ZkStat *zk.Stat    `json:"zkstat"`
	Data   interface{} `json:"data"`
}

type Ls

type Ls struct {
	Childrens []string `json:"childrens"`
	Path      string   `json:"path"`
	State     string   `json:"state"`
	Error     string   `json:"error"`
	ZkStat    *zk.Stat `json:"zkstat"`
}

Ls ...

type MC

type MC struct {
	Enabled bool     `json:"enabled"`
	Hosts   []string `json:"hosts"`
	Prefix  string   `json:"prefix"`
	Client  *memcache.Client
}

Memcached connection settings

func (MC) DeleteFromCache

func (mc MC) DeleteFromCache(key string) error

DeleteFromCache delete key from memcache

func (MC) GetFromCache

func (mc MC) GetFromCache(key string) ([]byte, error)

GetFromCache get node data from memcache

func (MC) InitConnection

func (mc MC) InitConnection() *memcache.Client

InitConnection to memcached cluster

func (MC) StoreToCache

func (mc MC) StoreToCache(key string, data []byte) error

StoreToCache save data to memecache

type Zk

type Zk struct {
	Hosts []string
	Path  string
	Tick  int
}

Zk Zookeeper connection settings

func (Zk) InitConnection

func (conf Zk) InitConnection() (*zk.Conn, error)

InitConnection Initialize Zookeeper connection

type ZooNode

type ZooNode struct {
	Path string
	Conn *zk.Conn
	Zoo  Zk
	MC   MC
}

ZooNode zookeeper node

func (ZooNode) CreateChild

func (z ZooNode) CreateChild(path string, content []byte) string

CreateChild create child in /node/path

func (ZooNode) CreateNode

func (z ZooNode) CreateNode(path string, content []byte) string

CreateNode ...

func (ZooNode) EnsureZooPath

func (z ZooNode) EnsureZooPath(path string) (string, error)

EnsureZooPath create zookeeper path

func (ZooNode) GET

func (zk ZooNode) GET(w http.ResponseWriter, r *http.Request)

GET ...

func (ZooNode) GetChildrens

func (z ZooNode) GetChildrens(path string) Ls

GetChildrens get Zookeeper node childrens

func (ZooNode) GetJSON

func (zk ZooNode) GetJSON(w http.ResponseWriter, r *http.Request)

GetJSON marshals the node data to the JSON

func (ZooNode) GetNode

func (z ZooNode) GetNode(path string) Get

GetNode data

func (ZooNode) LS

func (zk ZooNode) LS(w http.ResponseWriter, r *http.Request)

LS ...

func (ZooNode) RM

func (zk ZooNode) RM(w http.ResponseWriter, r *http.Request)

RM ...

func (ZooNode) RMR

func (z ZooNode) RMR(path string)

RMR remove Zk node recursive

func (ZooNode) UP

func (zk ZooNode) UP(w http.ResponseWriter, r *http.Request)

UP ...

func (ZooNode) UpdateNode

func (z ZooNode) UpdateNode(path string, content []byte) string

UpdateNode update existing node

Jump to

Keyboard shortcuts

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