Documentation ¶
Index ¶
- Constants
- func Abbreviate(str string, maxLength uint32) string
- func AddAndUpdateFinalizer(client client.Client, obj client.Object, finalizer string) error
- func AdmissionRequestObjectKeyString(req admission.Request) string
- func DeleteWithFinalizer(ctx context.Context, client client.Client, obj client.Object, finalizer string) error
- func Escape(key string) string
- func GetMapValue(m map[string]string, key string) (string, bool)
- func GetMapValueByDefault(m map[string]string, key, def string) string
- func MutateAnnotations(obj client.Object, mutateFn func(annotations map[string]string))
- func MutateLabels(obj client.Object, mutateFn func(labels map[string]string))
- func ObjectKeyString(obj client.Object) string
- func RemoveAndUpdateFinalizer(client client.Client, obj client.Object, finalizer string) error
- func SliceTopologyInfoEqual(a, b []v1alpha1.TopologyInfo) bool
- func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error) (int, error)
- func UpdateOnConflict(ctx context.Context, reader client.Reader, writer UpdateWriter, ...) (updated bool, err error)
- type UpdateWriter
Constants ¶
const (
SlowStartInitialBatchSize = 1
)
Variables ¶
This section is empty.
Functions ¶
func Abbreviate ¶
Abbreviate abbreviates a string using ellipses
func AddAndUpdateFinalizer ¶
func AdmissionRequestObjectKeyString ¶ added in v0.1.0
func DeleteWithFinalizer ¶ added in v0.1.0
func MutateAnnotations ¶ added in v0.1.0
func MutateLabels ¶ added in v0.1.0
func ObjectKeyString ¶
func SliceTopologyInfoEqual ¶ added in v0.1.0
func SliceTopologyInfoEqual(a, b []v1alpha1.TopologyInfo) bool
func SlowStartBatch ¶
func SlowStartBatch(count int, initialBatchSize int, shortCircuit bool, fn func(int, error) error) (int, error)
SlowStartBatch tries to call the provided function a total of 'count' times, starting slow to check for errors, then speeding up if calls succeed.
It groups the calls into batches, starting with a group of initialBatchSize. Within each batch, it may call the function multiple times concurrently.
If a whole batch succeeds, the next batch may get exponentially larger. If there are any failures in a batch, all remaining batches are skipped after waiting for the current batch to complete.
It returns the number of successful calls to the function.
func UpdateOnConflict ¶
func UpdateOnConflict(ctx context.Context, reader client.Reader, writer UpdateWriter, obj client.Object, mutateFn controllerutil.MutateFn) (updated bool, err error)
UpdateOnConflict attempts to update a resource while avoiding conflicts that may arise from concurrent modifications. It utilizes the mutateFn function to apply changes to the original obj and then attempts an update using the writer, which can be either client.Writer or client.StatusWriter. In case of an update failure due to a conflict, UpdateOnConflict will retrieve the latest version of the object using the reader and attempt the update again. The retry mechanism adheres to the retry.DefaultBackoff policy.
Types ¶
type UpdateWriter ¶
type UpdateWriter interface { // Update updates the fields corresponding to the status subresource for the // given obj. obj must be a struct pointer so that obj can be updated // with the content returned by the Server. Update(ctx context.Context, obj client.Object, opts ...client.UpdateOption) error }