application

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: May 4, 2021 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MetaServerSource    = "metaserver"
	ApplicationResource = "Application"
	ApplicationResp     = "applicationResponse"
	Ignore              = "ignore"
)

used to set Message.Route

View Source
const (
	// set by agent
	PreApplying applicationStatus = "PreApplying" // application is waiting to be sent to cloud
	InApplying  applicationStatus = "InApplying"  // application is sending to cloud

	// set by center
	InProcessing applicationStatus = "InProcessing" // application is in processing by cloud
	Approved     applicationStatus = "Approved"     // application is approved by cloud
	Rejected     applicationStatus = "Rejected"     // application is rejected by cloud

	// both
	Failed    applicationStatus = "Failed"    // failed to get application resp from cloud
	Completed applicationStatus = "Completed" // application is completed and waiting to be recycled
)
View Source
const (
	Get          applicationVerb = "get"
	List         applicationVerb = "list"
	Watch        applicationVerb = "watch"
	Create       applicationVerb = "create"
	Delete       applicationVerb = "delete"
	Update       applicationVerb = "update"
	UpdateStatus applicationVerb = "updatestatus"
	Patch        applicationVerb = "patch"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	Applications sync.Map //store struct application
	// contains filtered or unexported fields
}

used for generating application and do apply

func NewApplicationAgent

func NewApplicationAgent(nodeName string) *Agent

edged config.Config.HostnameOverride

func (*Agent) Apply

func (a *Agent) Apply(app *Application) error

func (*Agent) GC

func (a *Agent) GC()

func (*Agent) Generate

func (a *Agent) Generate(ctx context.Context, verb applicationVerb, option interface{}, obj runtime.Object) *Application

type Application

type Application struct {
	ID       string
	Key      string // group version resource namespaces name
	Verb     applicationVerb
	Nodename string
	Status   applicationStatus
	Reason   string // why in this status
	Option   []byte //
	ReqBody  []byte // better a k8s api instance
	RespBody []byte
	// contains filtered or unexported fields
}

record the resources that are in applying for requesting to be transferred down from the cloud, please: 0.use Agent.Generate to generate application 1.use Agent.Apply to apply application( generate msg and send it to cloud dynamiccontroller)

func (*Application) Call

func (a *Application) Call()

func (*Application) Close

func (a *Application) Close()

Close must be called when applicant no longer using application

func (*Application) GVR

func (*Application) Identifier

func (a *Application) Identifier() string

func (*Application) Namespace

func (a *Application) Namespace() string

func (*Application) OptionTo

func (a *Application) OptionTo(i interface{}) error

remember i must be a pointer to the initialized variable

func (*Application) ReqBodyTo

func (a *Application) ReqBodyTo(i interface{}) error

func (*Application) ReqContent

func (a *Application) ReqContent() interface{}

func (*Application) Reset

func (a *Application) Reset()

func (*Application) RespBodyTo

func (a *Application) RespBodyTo(i interface{}) error

func (*Application) RespContent

func (a *Application) RespContent() interface{}

func (*Application) String

func (a *Application) String() string

func (*Application) ToListener

func (a *Application) ToListener(option metav1.ListOptions) *SelectorListener

func (*Application) Wait

func (a *Application) Wait()

Wait the result of application after it is applied by application agent

type Center

type Center struct {
	Applications sync.Map
	HandlerCenter
	// contains filtered or unexported fields
}

func NewApplicationCenter

func NewApplicationCenter(dynamicSharedInformerFactory dynamicinformer.DynamicSharedInformerFactory) *Center

func (*Center) GC

func (c *Center) GC()

func (*Center) Process

func (c *Center) Process(msg model.Message)

Process translate msg to application , process and send resp to edge TODO: upgrade to parallel process

func (*Center) ProcessApplication

func (c *Center) ProcessApplication(app *Application) (interface{}, error)

ProcessApplication processes application by re-translating it to kube-api request with kube client, which will be processed and responced by apiserver eventually. Specially if app.verb == watch, it transform app to a listener and register it to HandlerCenter, rather then requetes to apiserver directly. Listener will then continuously listen kube-api change events and push them to edge node.

func (*Center) Response

func (c *Center) Response(app *Application, parentID string, status applicationStatus, reason string, respContent interface{})

Response update application, generate and send resp message to edge

type CommonResourceEventHandler

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

CommonResourceEventHandler can be used by configmapManager and podManager

func (*CommonResourceEventHandler) AddListener

func (*CommonResourceEventHandler) DeleteListener

func (c *CommonResourceEventHandler) DeleteListener(s *SelectorListener)

type HandlerCenter

type HandlerCenter interface {
	AddListener(s *SelectorListener) error
	DeleteListener(s *SelectorListener)
	ForResource(gvr schema.GroupVersionResource) *CommonResourceEventHandler
}

HandlerCenter is used to prepare corresponding CommonResourceEventHandler for listener CommonResourceEventHandler then will send to the listener the objs it is interested in, including subsequent changes (watch event)

func NewHandlerCenter

func NewHandlerCenter(informerFactory dynamicinformer.DynamicSharedInformerFactory) HandlerCenter

type LabelFieldSelector

type LabelFieldSelector struct {
	Label labels.Selector
	Field fields.Selector
}

TODO: how to solve json marshal unmashal problem against labels.Selector or fields.Selector?

func NewSelector

func NewSelector(ls string, fs string) LabelFieldSelector

func (*LabelFieldSelector) Fields

func (lf *LabelFieldSelector) Fields() fields.Selector

func (*LabelFieldSelector) Labels

func (lf *LabelFieldSelector) Labels() labels.Selector

func (*LabelFieldSelector) Match

func (lf *LabelFieldSelector) Match(set labels.Set, set2 fields.Set) bool

func (*LabelFieldSelector) MatchObj

func (lf *LabelFieldSelector) MatchObj(obj runtime.Object) bool

func (*LabelFieldSelector) String

func (lf *LabelFieldSelector) String() string

type PatchInfo

type PatchInfo struct {
	Name         string
	PatchType    types.PatchType
	Data         []byte
	Options      metav1.PatchOptions
	Subresources []string
}

type SelectorListener

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

func NewSelectorListener

func NewSelectorListener(nodeName string, gvr schema.GroupVersionResource, selector LabelFieldSelector) *SelectorListener

Jump to

Keyboard shortcuts

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