resource

package
v0.0.0-...-10d5974 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2024 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttrKey

type AttrKey int
const (
	NamespaceAttr AttrKey = 0x0000

	// K8sPod
	ContainerIDsAttr AttrKey = 0x0010 // string containerID1,containerID2,...
	PodLabelsAttr    AttrKey = 0x0011 // extra map[string]string
	PodIP            AttrKey = 0x0012 // string
	PodPhase         AttrKey = 0x0013 // string Pending / Running
	PodHostName      AttrKey = 0x0014 // string
	PodHostIP        AttrKey = 0x0015 // string
	PodHostNetwork   AttrKey = 0x0016 // bool
	Name2Port        AttrKey = 0x0017 // extra map[string]string

	// K8sService
	ServiceSelectorsAttr     AttrKey = 0x0020 // extra map[string]string
	ServiceIP                AttrKey = 0x0021 // string
	ServiceEndpoints         AttrKey = 0x0022 // string ip1,ip2,...
	ServicePorts2TargetPorts AttrKey = 0x0023 // string name:port-targetPort-nodePort,name2:port-targetPort-nodePort

	// Node
	NodeInternalIP AttrKey = 0x0030
	NodeExternalIP AttrKey = 0x0031
	NodeHostName   AttrKey = 0x0032

	// OwnerAttribute
	OwnerName AttrKey = 0x0111
	OwnerType AttrKey = 0x0112
)

K8sMetadata

type CheckPoint

type CheckPoint struct {
	AgentIndex int64
	Timestamp  int64
	EventIndex int
}

func (*CheckPoint) Equals

func (p *CheckPoint) Equals(cp *CheckPoint) bool

type Exporter

type Exporter interface {
	SetupResourcesRef(resources *Resources)
	ExportResourceEvents(events *ResourceEvent)
}

type FetchRequest

type FetchRequest struct {
	ResourceTypes []ResType
}

type HandlerTemplate

type HandlerTemplate func(resType ResType, resources []*Resource) ResHandler

type Relation

type Relation struct {
	ResUID ResUID
	ReType RelationType

	StringAttr map[AttrKey]string `json:"strAttrMap"`
}

type RelationRef

type RelationRef struct {
	Relation
	Res *Resource
}

type RelationType

type RelationType int
const (
	R_OWNER    RelationType = 0x0001
	R_ENDPOINT RelationType = 0x0003
)

type ResHandler

type ResHandler interface {
	AddResource(res *Resource)
	UpdateResource(res *Resource)
	DeleteResource(res *Resource)
	Reset(resList []*Resource)

	SetClusterID(clusterID string)
	SetExporter(Exporter)
}

type ResOperation

type ResOperation int
const (
	AddOP    ResOperation = 0
	UpdateOP ResOperation = 1
	DeleteOP ResOperation = 2

	ResetOP ResOperation = 3
)

type ResType

type ResType int
const (
	PodType     ResType = 0x0001
	ServiceType ResType = 0x0002
	NodeType    ResType = 0x0003
)

type ResUID

type ResUID string

type ResVersion

type ResVersion string

type Resource

type Resource struct {
	ResUID
	ResType

	// Last updated timestamp
	ResVersion

	Name string `json:"name"`

	Relations []Relation `json:"relations"`

	StringAttr map[AttrKey]string `json:"strAttrMap"`
	Int64Attr  map[AttrKey]int64  `json:"int64AttrMap"`

	// Labels for Pod
	// Selector for services
	ExtraAttr map[AttrKey]map[string]string `json:"extraInfo"`
}

type ResourceEvent

type ResourceEvent struct {
	// 事件来源的集群ID
	ClusterID string

	Res          []*Resource
	ResourceType ResType
	Operation    ResOperation
}

type Resources

type Resources struct {
	ResList []*Resource
	ResType ResType

	ClusterID string

	// add lock/unlock...
	ExportMux sync.RWMutex
	Exporter
}

func NewResources

func NewResources(resType ResType, resList []*Resource) *Resources

func (*Resources) AddResource

func (rs *Resources) AddResource(res *Resource)

func (*Resources) DeleteResource

func (rs *Resources) DeleteResource(res *Resource)

func (*Resources) Reset

func (rs *Resources) Reset(res []*Resource)

func (*Resources) SetClusterID

func (rs *Resources) SetClusterID(clusterID string)

func (*Resources) SetExporter

func (rs *Resources) SetExporter(exporter Exporter)

func (*Resources) UpdateResource

func (rs *Resources) UpdateResource(res *Resource)

type SyncRequest

type SyncRequest struct {
	Events []*ResourceEvent
	// 上次更新时间
	LastCheckPoint *CheckPoint
	// 本次更新结束时间
	CheckPoint *CheckPoint
}

func (*SyncRequest) IsHealthCheck

func (r *SyncRequest) IsHealthCheck() bool

IsHealthCheck 是否是初始化信号 LastCheckPoint为nil,表示未曾提交过数据,此时不会提供其他数据

func (*SyncRequest) IsInitRequest

func (r *SyncRequest) IsInitRequest() bool

func (*SyncRequest) IsSyncCheck

func (r *SyncRequest) IsSyncCheck() bool

IsSyncCheck 是否是同步检查信号 CheckPoint和Events都为nil, 表示不做更新, 仅检查LastCheckPoint状态

type SyncResponse

type SyncResponse struct {
	LastCheckPoint *CheckPoint
	IsStopPush     bool
	IsInit         bool
	IsAccepted     bool
}

Jump to

Keyboard shortcuts

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