scheduler

package
v0.0.0-...-d3601d1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2018 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetTargetNode

func GetTargetNode(backends map[string]Upstream, block int64, lastblock *EthBlock, maxresponsetime int64) (*url.URL, error)

Types

type Config

type Config struct {
	Port            string
	Bind            string
	AdminPort       string
	WebSocket       string
	Suspend         int
	Ticker          int
	MaxResponseTime int64
	SocketPath      string
	Slack           slackConfig
	Telegram        telegramConfig
	Servers         []server
}

Config is struct for config.toml file

type EthBlock

type EthBlock struct {
	Dig        int64 `json:"block"`
	Hex        string
	Token      string `json:"token"`
	TimeUpdate int64  `json:"lastupdate"`
	Mutex      sync.RWMutex
}

type JSONRPCMessage

type JSONRPCMessage struct {
	Version string            `json:"jsonrpc"`
	ID      int               `json:"id,omitempty"`
	Method  string            `json:"method,omitempty"`
	Params  []json.RawMessage `json:"params,omitempty"`
	Error   *jsonError        `json:"error,omitempty"`
	Result  json.RawMessage   `json:"result,omitempty"`
}

JSONRPCMessage structure for mapping request from ethclient

func (JSONRPCMessage) GetStringParams

func (req JSONRPCMessage) GetStringParams(index int) (string, error)

GetStringParams return index string from params field of request

type Upstream

type Upstream struct {
	Port         uint16     `json:"-"`
	TimeUpdate   int64      `json:"lastupdate"`
	Weight       uint8      `json:"weight"`
	Backup       bool       `json:"-"`
	Host         string     `json:"-"`
	Hostname     string     `json:"hostname"`
	Target       string     `json:"url"`
	Token        string     `json:"-"`
	LastBlock    int64      `json:"digblock"`
	ResponseTime int64      `json:"responsetime"`
	HexLastBlock string     `json:"lastblock"`
	State        string     `json:"-"`
	RealState    string     `json:"status"`
	FSM          *fsm.FSM   `json:"-"`
	Mutex        sync.Mutex `json:"-"`
}

Upstream is host for reverseproxy request from ethclients

func NewUpstream

func NewUpstream(host string, port string, weight int, token string, hostname string) *Upstream

NewUpstream is constructor for Upstream

func (*Upstream) GetTargetLastBlock

func (u *Upstream) GetTargetLastBlock(ctx context.Context, LastBlock *EthBlock)

func (*Upstream) GetURL

func (u *Upstream) GetURL() (*url.URL, error)

GetURL return url.URL from target filed shema://host:port

func (*Upstream) UpdateLastBlock

func (u *Upstream) UpdateLastBlock(hexLastBlock string) error

UpdateLastBlock function for update some fileds in Upstrea: LastBlock value, TimeUpdate value and state to UP

Jump to

Keyboard shortcuts

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