Documentation
¶
Index ¶
- Constants
- type Action
- type App
- func (a *App) Cancel(hostname string, latestTime int64) (i *Instance, l int, ok bool)
- func (a *App) Instances() (is []*Instance)
- func (a *App) Len() (l int)
- func (a *App) NewInstance(ni *Instance, latestTime int64) (i *Instance, ok bool)
- func (a *App) Renew(hostname string) (i *Instance, ok bool)
- func (a *App) Set(changes *ArgSet) (ok bool)
- type Apps
- func (p *Apps) App(zone string) (as []*App)
- func (p *Apps) Del(zone string)
- func (p *Apps) InstanceInfo(zone string, latestTime int64, status uint32) (ci *InstanceInfo, err error)
- func (p *Apps) NewApp(zone, appid string, treeid, lts int64) (a *App, new bool)
- func (p *Apps) UpdateLatest(latestTime int64)
- type ArgCancel
- type ArgFetch
- type ArgFetchs
- type ArgPoll
- type ArgPolling
- type ArgPolls
- type ArgRegister
- type ArgRenew
- type ArgSet
- type Instance
- type InstanceInfo
- type Node
- type NodeStatus
Constants ¶
const ( // InstanceStatusUP Ready to receive traffic InstanceStatusUP = uint32(1) // InstancestatusWating Intentionally shutdown for traffic InstancestatusWating = uint32(1) << 1 )
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 ¶
App Instances distinguished by hostname
func (*App) NewInstance ¶
NewInstance new a instance.
type Apps ¶
type Apps struct {
// contains filtered or unexported fields
}
Apps app distinguished 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) UpdateLatest ¶
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.
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 )