Documentation ¶
Index ¶
- Constants
- func GetAppStateStatus(id watcher.Identity, services []*ServiceState, desired int) watcher.Status
- func GetContainerStateStatus(state ContainerState) (watcher.Status, *watcher.ContainerStatusSource)
- func GetPodStatus(pod Pod) watcher.Status
- func GetServiceStateStatus(id watcher.Identity, pods []watcher.Status, replicas int) watcher.Status
- func WithLock(lockable Lockable, fn func())
- func WithReadLock(lockable ReadLockable, fn func())
- type AppState
- type ContainerState
- type Database
- type Identifiable
- type Identificator
- type Lockable
- type Observer
- type Pod
- type PodName
- type Proc
- type ReadLockable
- type ReplicaSpec
- type ServiceState
- func (service *ServiceState) GetPodStatus(name string) (watcher.Status, bool)
- func (service *ServiceState) GetReplicas() int
- func (service *ServiceState) GetStatus() watcher.Status
- func (service *ServiceState) IsSameContainerState(container uuid.UUID, state ContainerState) bool
- func (service *ServiceState) RemovePodStatus(name string)
- func (service *ServiceState) SetContainerState(container uuid.UUID, state ContainerState)
- func (service *ServiceState) SetPodStatus(name string, status watcher.Status)
- func (service *ServiceState) SetReplicas(replicas int)
- func (service *ServiceState) SetStatus(status watcher.Status)
- type States
- type StatusChanger
- type Syncer
Constants ¶
const ( // AverageWindow number of points to keep AverageWindow = 1000 // RateDuration duration to keep the items RateDuration = time.Second )
Variables ¶
This section is empty.
Functions ¶
func GetAppStateStatus ¶
GetAppStateStatus a helper function to get the status of the app
func GetContainerStateStatus ¶
func GetContainerStateStatus(state ContainerState) (watcher.Status, *watcher.ContainerStatusSource)
GetContainerStateStatus a helper function to get the status of the container
func GetPodStatus ¶
GetPodStatus a helper function to get the status of a pod
func GetServiceStateStatus ¶
GetServiceStateStatus a helper function to get the status of the service
func WithReadLock ¶
func WithReadLock(lockable ReadLockable, fn func())
WithReadLock runs a function with read lock
Types ¶
type AppState ¶
AppState holds application (namespace) state
func (*AppState) GetService ¶
func (app *AppState) GetService(id uuid.UUID) (*ServiceState, bool)
GetService gets a service with id
func (*AppState) NewService ¶
func (app *AppState) NewService( id uuid.UUID, ) *ServiceState
NewService creates a new service with a given id
func (*AppState) SetDesiredServices ¶
SetDesiredServices setter for AppState.desiredServices
type ContainerState ¶
type ContainerState struct { Current kapi.ContainerState LastTerminationState kapi.ContainerState }
ContainerState a struct to hold the container state it keeps the last termination state to detect OOMs in case of CrashLoops
func (*ContainerState) IsOOMKilled ¶
func (state *ContainerState) IsOOMKilled() bool
IsOOMKilled returns if the service is oom killed
type Database ¶
type Database interface { WriteEvent(event *watcher.Event) error WriteEvents(events []*watcher.Event) error }
Database eventer
type Identifiable ¶
type Identifiable interface { GetLabels() map[string]string GetNamespace() string GetName() string GroupVersionKind() schema.GroupVersionKind }
Identifiable an identifiable kubernetes entity
type Identificator ¶
type Identificator interface { GetID(resource Identifiable) (string, error) GetAccountID(resource Identifiable) (uuid.UUID, error) GetApplicationID(resource Identifiable) (uuid.UUID, error) GetServiceID(resource Identifiable) (uuid.UUID, error) GetContainerID(pod Identifiable, containerName string) (uuid.UUID, error) IsIgnored(resource Identifiable) bool }
Identificator an interface to represent entities able to identify identifiables
type Lockable ¶
type Lockable interface { Lock() Unlock() }
Lockable Same interface as sync.Locker but sync package doesn't have interface for read locker
type Observer ¶
type Observer struct {
// contains filtered or unexported fields
}
Observer kubernetes objects observer
func NewObserver ¶
func NewObserver( clientset *kubernetes.Clientset, clientV1 *v1client.AppsV1Client, batchV1Beta1 *beta1batchclient.BatchV1beta1Client, identificator Identificator, health *health.Health, ) *Observer
NewObserver creates a new observer
func (*Observer) GetPipePods ¶
GetPipePods getter for observer.pods
func (*Observer) GetPipeReplicas ¶
func (observer *Observer) GetPipeReplicas() chan ReplicaSpec
GetPipeReplicas getter for observer.replicas
func (*Observer) SetSyncCallback ¶
func (observer *Observer) SetSyncCallback(fn func())
SetSyncCallback setter for sync callback
type Pod ¶
type Pod struct { Name string `json:"name"` ID string `json:"id"` AccountID uuid.UUID `json:"account_id"` ApplicationID uuid.UUID `json:"application_id"` ServiceID uuid.UUID `json:"service_id"` Status watcher.Status `json:"status"` Containers map[uuid.UUID]ContainerState `json:"containers"` }
Pod pod type
func (*Pod) GetIdentity ¶
GetIdentity returns an identity for the pod
type Proc ¶
type Proc struct {
// contains filtered or unexported fields
}
Proc events processor
func NewProc ¶
func NewProc( pods chan Pod, replicas chan ReplicaSpec, changer StatusChanger, database Database, threads int, health *health.Health, ) *Proc
NewProc creates a new processor
type ReadLockable ¶
type ReadLockable interface { RLock() RUnlock() }
ReadLockable defines only read lock functions
type ReplicaSpec ¶
type ReplicaSpec struct { Name string ID string AccountID uuid.UUID ApplicationID uuid.UUID ServiceID uuid.UUID Replicas int }
ReplicaSpec returns an identity for a replicated service
func (*ReplicaSpec) GetIdentity ¶
func (spec *ReplicaSpec) GetIdentity() watcher.Identity
GetIdentity returns an identity for the service
type ServiceState ¶
ServiceState defines the service state
func (*ServiceState) GetPodStatus ¶
func (service *ServiceState) GetPodStatus(name string) (watcher.Status, bool)
GetPodStatus returns the status of a pod by its name that belongs to the service
func (*ServiceState) GetReplicas ¶
func (service *ServiceState) GetReplicas() int
GetReplicas getter for service.replicas
func (*ServiceState) GetStatus ¶
func (service *ServiceState) GetStatus() watcher.Status
GetStatus getter for service.status
func (*ServiceState) IsSameContainerState ¶
func (service *ServiceState) IsSameContainerState( container uuid.UUID, state ContainerState, ) bool
IsSameContainerState checks if the state is the same for a container inside the service
func (*ServiceState) RemovePodStatus ¶
func (service *ServiceState) RemovePodStatus(name string)
RemovePodStatus removes pod status by name
func (*ServiceState) SetContainerState ¶
func (service *ServiceState) SetContainerState( container uuid.UUID, state ContainerState, )
SetContainerState setter for container state
func (*ServiceState) SetPodStatus ¶
func (service *ServiceState) SetPodStatus(name string, status watcher.Status)
SetPodStatus sets a status for a pod by its name
func (*ServiceState) SetReplicas ¶
func (service *ServiceState) SetReplicas(replicas int)
SetReplicas setter for service,replicas represents the number of replicas of the service
func (*ServiceState) SetStatus ¶
func (service *ServiceState) SetStatus(status watcher.Status)
SetStatus setter for service.status
type StatusChanger ¶
type StatusChanger interface { GetApplicationDesiredServices(uuid.UUID) ([]uuid.UUID, error) ChangeStatus(string, uuid.UUID, watcher.Status, *watcher.ContainerStatusSource) }
StatusChanger interface for status changer
type Syncer ¶
type Syncer struct {
// contains filtered or unexported fields
}
Syncer keeps track of synced entities
func (*Syncer) InformResource ¶
InformResource set version and sync resource