Documentation ¶
Index ¶
- Constants
- type Agent
- type Application
- func (a *Application) Call()
- func (a *Application) Close()
- func (a *Application) GVR() schema.GroupVersionResource
- func (a *Application) Identifier() string
- func (a *Application) Namespace() string
- func (a *Application) OptionTo(i interface{}) error
- func (a *Application) ReqBodyTo(i interface{}) error
- func (a *Application) ReqContent() interface{}
- func (a *Application) Reset()
- func (a *Application) RespBodyTo(i interface{}) error
- func (a *Application) RespContent() interface{}
- func (a *Application) String() string
- func (a *Application) ToListener(option metav1.ListOptions) *SelectorListener
- func (a *Application) Wait()
- type Center
- type CommonResourceEventHandler
- type HandlerCenter
- type LabelFieldSelector
- type PatchInfo
- type SelectorListener
Constants ¶
const ( MetaServerSource = "metaserver" ApplicationResource = "Application" ApplicationResp = "applicationResponse" Ignore = "ignore" )
used to set Message.Route
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 )
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 ¶
edged config.Config.HostnameOverride
func (*Agent) Apply ¶
func (a *Agent) Apply(app *Application) error
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 (a *Application) GVR() schema.GroupVersionResource
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) Process ¶
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.
type CommonResourceEventHandler ¶
type CommonResourceEventHandler struct {
// contains filtered or unexported fields
}
CommonResourceEventHandler can be used by configmapManager and podManager
func NewCommonResourceEventHandler ¶
func NewCommonResourceEventHandler(gvr schema.GroupVersionResource, informerFactory dynamicinformer.DynamicSharedInformerFactory, layer messagelayer.MessageLayer) *CommonResourceEventHandler
func (*CommonResourceEventHandler) AddListener ¶
func (c *CommonResourceEventHandler) AddListener(s *SelectorListener) error
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 ¶
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) MatchObj ¶
func (lf *LabelFieldSelector) MatchObj(obj runtime.Object) bool
func (*LabelFieldSelector) String ¶
func (lf *LabelFieldSelector) String() string
type SelectorListener ¶
type SelectorListener struct {
// contains filtered or unexported fields
}
func NewSelectorListener ¶
func NewSelectorListener(nodeName string, gvr schema.GroupVersionResource, selector LabelFieldSelector) *SelectorListener