Documentation
¶
Index ¶
- type Actor
- type AddHook
- type AddHookFunc
- type Builder
- type DelHook
- type DelHookFunc
- type Executor
- type Metadata
- type NewFactory
- type NewFunc
- type Patch
- type PreferPolicy
- type PreferPolicyFunc
- type Score
- type ScoredPreferPolicy
- type Selector
- type Spec
- type State
- type UnlockFunc
- type UpdateHook
- type UpdateHookFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Actor ¶
type Actor interface {
// ScaleOut creates a new update instance
ScaleOut(ctx context.Context) error
// Update will update an instance CR
// unavailable means update must choose an unavailable instance to update
Update(ctx context.Context, unavailable bool) error
// ScaleInOutdated will scale in an outdated instance
// If unavailable is true, the chosen instance is unavailable
ScaleInUpdate(ctx context.Context) (unavailable bool, _ error)
// ScaleInUpdate will scale in an updated instance
// If unavailable is true, the chosen instance is unavailable
ScaleInOutdated(ctx context.Context) (unavailable bool, _ error)
// Cleanup deletes all instances marked as defer deletion
Cleanup(ctx context.Context) error
}
type AddHook ¶
AddHook a hook executes when add an instance. e.g. for topology scheduling
func AllocateName ¶
AllocateName will set name for new instance If a new name is allocated, it will be recorded until it is observed. This hook is defined to avoid dirty read(no read-after-write consistency) when scale out. For example, when a new item is created but not observed in next reconciliation, updater will create a new one again with a new name. It means an unexpected item may be created. This hook can ensure that updater will try to create the item again if it is not observed
type AddHookFunc ¶
func (AddHookFunc[PT]) Add ¶
func (f AddHookFunc[PT]) Add(update PT) PT
type Builder ¶
type Builder[R runtime.Instance] interface { WithInstances(...R) Builder[R] WithDesired(desired int) Builder[R] WithMaxSurge(maxSurge int) Builder[R] WithRevision(rev string) Builder[R] WithClient(c client.Client) Builder[R] WithNewFactory(NewFactory[R]) Builder[R] WithAddHooks(hooks ...AddHook[R]) Builder[R] WithUpdateHooks(hooks ...UpdateHook[R]) Builder[R] WithDelHooks(hooks ...DelHook[R]) Builder[R] WithScaleInPreferPolicy(ps ...PreferPolicy[R]) Builder[R] WithUpdatePreferPolicy(ps ...PreferPolicy[R]) Builder[R] // NoInPlaceUpdate if true, actor will use Scale in and Scale out to replace Update operation WithNoInPaceUpdate(noUpdate bool) Builder[R] // MinReadySeconds means instances are available only when they keep ready more than minReadySeconds WithMinReadySeconds(minReadySeconds int64) Builder[R] Build() Executor }
type DelHookFunc ¶
func (DelHookFunc[PT]) Delete ¶
func (f DelHookFunc[PT]) Delete(name string)
type Executor ¶
Executor is an executor that updates the instances. TODO: return instance list after Do
func NewExecutor ¶
type NewFactory ¶
type NewFactory[R runtime.Instance] interface { // New will generate a new object for scaling out and update. New() R // Adopt is only called when scaling out. // UnlockFunc will be called if apply is failed. // If no obj can be adopted, obj is nil and exists is false. // // This interface cannot ensure that R is a pointer(of course it is), so a // return val 'exists' is added to check whether the obj is nil. // We can add a new generic type param(runtime.InstanceSet) to ensure that R is a pointer, but it changes too much. Adopt() (obj R, fn UnlockFunc, exists bool) }
NewFactory try to New a object to scale out The object returned by New may be - Doesn't exist, the obj will be created - Exists but is not managed, the obj will be adpoted The adopting obj will be locked until apply is done If apply is failed, we should call unlock to release the adopting object, so that it can be adopted by others.
type NewFunc ¶
func (NewFunc[R]) Adopt ¶
func (f NewFunc[R]) Adopt() (obj R, fn UnlockFunc, exists bool)
type PreferPolicy ¶
func PreferNotRunning ¶
func PreferNotRunning[R runtime.Instance]() PreferPolicy[R]
func PreferUnready ¶
func PreferUnready[R runtime.Instance]() PreferPolicy[R]
type PreferPolicyFunc ¶
func (PreferPolicyFunc[R]) Prefer ¶
func (f PreferPolicyFunc[R]) Prefer(in []R) []R
type ScoredPreferPolicy ¶
type Selector ¶
func NewSelector ¶
func NewSelector[R runtime.Instance](ps ...PreferPolicy[R]) Selector[R]
type State ¶
type UnlockFunc ¶
type UnlockFunc func()
type UpdateHook ¶
UpdateHook a hook executes when update an instance. e.g. for some write once fields(name, topology, etc.)
func KeepName ¶
func KeepName[R runtime.Instance]() UpdateHook[R]
KeepName does not change name when update obj
func KeepResourceVersion ¶
func KeepResourceVersion[R runtime.Instance]() UpdateHook[R]
KeepResourceVersion set resourceVersion when update obj
func KeepTopology ¶
func KeepTopology[R runtime.Instance]() UpdateHook[R]
KeepTopology does not change topology when update obj
type UpdateHookFunc ¶
func (UpdateHookFunc[R]) Update ¶
func (f UpdateHookFunc[R]) Update(update, outdated R) R