model

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InstanceStatusUP Ready to receive traffic
	InstanceStatusUP = uint32(1)
	// InstancestatusWating Intentionally shutdown for traffic
	InstancestatusWating = uint32(1) << 1
)
View Source
const (
	// AppID is discvoery id
	AppID = "infra.discovery"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action int

Action Replicate type of node

const (
	// Register Replicate the add action to all nodes
	Register Action = iota
	// Renew Replicate the heartbeat action to all nodes
	Renew
	// Cancel Replicate the cancel action to all nodes
	Cancel
	// Weight Replicate the Weight action to all nodes
	Weight
	// Delete Replicate the Delete action to all nodes
	Delete
	// Status Replicate the Status action to all nodes
	Status
)

type App

type App struct {
	AppID  string
	Treeid int64
	Zone   string
	// contains filtered or unexported fields
}

App Instances distinguished by hostname

func NewApp

func NewApp(zone, appid string, treeid int64) (a *App)

NewApp new App.

func (*App) Cancel

func (a *App) Cancel(hostname string, latestTime int64) (i *Instance, l int, ok bool)

Cancel cancel a instance.

func (*App) Instances

func (a *App) Instances() (is []*Instance)

Instances return slice of instances.

func (*App) Len

func (a *App) Len() (l int)

Len returns the length of instances.

func (*App) NewInstance

func (a *App) NewInstance(ni *Instance, latestTime int64) (i *Instance, ok bool)

NewInstance new a instance.

func (*App) Renew

func (a *App) Renew(hostname string) (i *Instance, ok bool)

Renew new a instance.

func (*App) Set

func (a *App) Set(changes *ArgSet) (ok bool)

Set set new status,metadata of instance .

type Apps

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

Apps app distinguished by zone

func NewApps

func NewApps() *Apps

NewApps return new Apps.

func (*Apps) App

func (p *Apps) App(zone string) (as []*App)

App get app by zone.

func (*Apps) Del

func (p *Apps) Del(zone string)

Del del app by zone.

func (*Apps) InstanceInfo

func (p *Apps) InstanceInfo(zone string, latestTime int64, status uint32) (ci *InstanceInfo, err error)

InstanceInfo return slice of instances.if up is true,return all status instance else return up status instance

func (*Apps) NewApp

func (p *Apps) NewApp(zone, appid string, treeid, lts int64) (a *App, new bool)

NewApp news a app by appid. If ok=false, returns the app of already exist.

func (*Apps) UpdateLatest

func (p *Apps) UpdateLatest(latestTime int64)

UpdateLatest update LatestTimestamp.

type ArgCancel

type ArgCancel struct {
	Region          string `form:"region"`
	Zone            string `form:"zone" validate:"required"`
	Env             string `form:"env" validate:"required"`
	Appid           string `form:"appid" validate:"required"`
	Treeid          int64  `form:"treeid"`
	Hostname        string `form:"hostname" validate:"required"`
	Replication     bool   `form:"replication"`
	LatestTimestamp int64  `form:"latest_timestamp"`
}

ArgCancel define cancel params.

type ArgFetch

type ArgFetch struct {
	Region string `form:"region"`
	Zone   string `form:"zone"`
	Env    string `form:"env" validate:"required"`
	Appid  string `form:"appid"`
	Treeid int64  `form:"treeid"`
	Status uint32 `form:"status" validate:"required"`
}

ArgFetch define fetch param.

type ArgFetchs

type ArgFetchs struct {
	Zone   string   `form:"zone"`
	Env    string   `form:"env" validate:"required"`
	Appid  []string `form:"appid,split"`
	Status uint32   `form:"status" validate:"required"`
}

ArgFetchs define fetchs arg.

type ArgPoll

type ArgPoll struct {
	Region          string `form:"region"`
	Zone            string `form:"zone"`
	Env             string `form:"env" validate:"required"`
	Appid           string `form:"appid"`
	Treeid          int64  `form:"treeid"`
	Hostname        string `form:"hostname" validate:"required"`
	LatestTimestamp int64  `form:"latest_timestamp"`
}

ArgPoll define poll param.

type ArgPolling

type ArgPolling struct {
	Zone  string `form:"zone"`
	Env   string `form:"env" validate:"required"`
	Appid string `form:"appid"`
}

ArgPolling define polling arg.

type ArgPolls

type ArgPolls struct {
	Region          string   `form:"region"`
	Zone            string   `form:"zone"`
	Env             string   `form:"env" validate:"required"`
	Appid           []string `form:"appid,split"`
	Treeid          []int64  `form:"treeid,split"`
	Hostname        string   `form:"hostname,split" validate:"required"`
	LatestTimestamp []int64  `form:"latest_timestamp,split"`
}

ArgPolls define poll param.

type ArgRegister

type ArgRegister struct {
	Region          string   `form:"region"`
	Zone            string   `form:"zone" validate:"required"`
	Env             string   `form:"env" validate:"required"`
	Appid           string   `form:"appid" validate:"required"`
	Treeid          int64    `form:"treeid"`
	Hostname        string   `form:"hostname" validate:"required"`
	Status          uint32   `form:"status" validate:"required"`
	HTTP            string   `form:"http"`
	RPC             string   `form:"rpc"`
	Version         string   `form:"version"`
	Metadata        string   `form:"metadata"`
	Replication     bool     `form:"replication"`
	Addrs           []string `form:"addrs,split"`
	LatestTimestamp int64    `form:"latest_timestamp"`
	DirtyTimestamp  int64    `form:"dirty_timestamp"`
}

ArgRegister define register param.

type ArgRenew

type ArgRenew struct {
	Region         string `form:"region"`
	Zone           string `form:"zone" validate:"required"`
	Env            string `form:"env" validate:"required"`
	Appid          string `form:"appid" validate:"required"`
	Treeid         int64  `form:"treeid"`
	Hostname       string `form:"hostname" validate:"required"`
	Replication    bool   `form:"replication"`
	DirtyTimestamp int64  `form:"dirty_timestamp"`
}

ArgRenew define renew params.

type ArgSet

type ArgSet struct {
	Region       string   `form:"region"`
	Zone         string   `form:"zone" validate:"required"`
	Env          string   `form:"env" validate:"required"`
	Appid        string   `form:"appid" validate:"required"`
	Hostname     []string `form:"hostname,split"`
	Status       []int64  `form:"status,split"`
	Metadata     []string `form:"metadata"`
	Replication  bool     `form:"replication"`
	SetTimestamp int64    `form:"set_timestamp"`
}

ArgSet define set param.

type Instance

type Instance struct {
	Region   string            `json:"region"`
	Zone     string            `json:"zone"`
	Env      string            `json:"env"`
	Appid    string            `json:"appid"`
	Treeid   int64             `json:"treeid"`
	Hostname string            `json:"hostname"`
	HTTP     string            `json:"http"`
	RPC      string            `json:"rpc"`
	Version  string            `json:"version"`
	Metadata map[string]string `json:"metadata"`
	Addrs    []string          `json:"addrs"`
	// Status enum instance status
	Status uint32 `json:"status"`

	// timestamp
	RegTimestamp   int64 `json:"reg_timestamp"`
	UpTimestamp    int64 `json:"up_timestamp"` // NOTE: It is latest timestamp that status becomes UP.
	RenewTimestamp int64 `json:"renew_timestamp"`
	DirtyTimestamp int64 `json:"dirty_timestamp"`

	LatestTimestamp int64 `json:"latest_timestamp"`
}

Instance holds information required for registration with <Discovery Server> and to be discovered by other components.

func NewInstance

func NewInstance(arg *ArgRegister) (i *Instance)

NewInstance new a instance.

type InstanceInfo

type InstanceInfo struct {
	Instances          []*Instance            `json:"instances"`
	ZoneInstances      map[string][]*Instance `json:"zone_instances"`
	LatestTimestamp    int64                  `json:"latest_timestamp"`
	LatestTimestampStr string                 `json:"latest_timestamp_str"`
}

InstanceInfo the info get by consumer.

type Node

type Node struct {
	Addr   string     `json:"addr"`
	Status NodeStatus `json:"status"`
	Zone   string     `json:"zone"`
}

Node node

type NodeStatus

type NodeStatus int

NodeStatus Status of instance

const (
	// NodeStatusUP Ready to receive register
	NodeStatusUP NodeStatus = iota
	// NodeStatusLost lost with each other
	NodeStatusLost
)

Jump to

Keyboard shortcuts

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