web

package
v0.0.0-...-3bc59d9 Latest Latest
Warning

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

Go to latest
Published: May 31, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAgentServer

func NewAgentServer(host, port string)

NewAgentServer function create the http api

func NewServer

func NewServer() error

NewServer function create the http api

func SetupLogger

func SetupLogger()

Types

type GlobalMessages

type GlobalMessages struct {
	MaxSize int
	Events  []Message `json:"events"`
	// contains filtered or unexported fields
}

GlobalMessages define the Messages Manager

var MessagesHub *GlobalMessages

MessagesHub for global message hub

func NewGloabalMessages

func NewGloabalMessages(max int) *GlobalMessages

NewGloabalMessages create a new messages manager

func (*GlobalMessages) Get

func (g *GlobalMessages) Get() ([]byte, error)

Get get current message and delete it from messages manager

func (*GlobalMessages) Len

func (g *GlobalMessages) Len() int

Len return current message length

func (*GlobalMessages) Write

func (g *GlobalMessages) Write(p []byte) (n int, err error)

type IPWithPort

type IPWithPort struct {
	IPAddress string `json:"ipaddress" valid:"ip"`
	Port      string `json:"port" valid:"port"`
	Enable    bool   `json:"enable" valid:"-"`
}

IPWithPort define the posted node info

func (*IPWithPort) Validate

func (ipp *IPWithPort) Validate() error

Validate if ip and port infomation is valid

type JSONResponse

type JSONResponse struct {
	CurrentMessages []Message       `json:"messages"`
	ID              string          `json:"id"`
	Status          string          `json:"status"`
	Error           string          `json:"error"`
	NodeInfos       []core.NodeInfo `json:"nodes"`
}

JSONResponse the response to front end

type Message

type Message struct {
	Level  string `json:"level"`
	Time   string `json:"time"`
	Msg    string `json:"msg"`
	Result bool   `json:"result"`
}

Message define one single event message

type MyHook

type MyHook struct{}

MyHook 定义logrus的hook类型

func (*MyHook) Fire

func (h *MyHook) Fire(entry *log.Entry) (err error)

Fire 必须实施的接口类型,将打印的信息进行格式化,此处使用text格式化

func (*MyHook) Levels

func (h *MyHook) Levels() []log.Level

Levels return all log level for Hooks

Jump to

Keyboard shortcuts

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