github.com/cilium/cilium@v1.16.2/pkg/ipam/service/allocator/interfaces.go (about)

     1  // SPDX-License-Identifier: Apache-2.0
     2  // Copyright Authors of Cilium
     3  // Copyright The Kubernetes Authors.
     4  
     5  package allocator
     6  
     7  // Interface manages the allocation of items out of a range. Interface
     8  // should be threadsafe.
     9  type Interface interface {
    10  	Allocate(int) (bool, error)
    11  	AllocateNext() (int, bool, error)
    12  	Release(int)
    13  	ForEach(func(int))
    14  	Has(int) bool
    15  	Free() int
    16  }
    17  
    18  // Snapshottable is an Interface that can be snapshotted and restored. Snapshottable
    19  // should be threadsafe.
    20  type Snapshottable interface {
    21  	Interface
    22  	Snapshot() (string, []byte)
    23  	Restore(string, []byte) error
    24  }
    25  
    26  type AllocatorFactory func(max int, rangeSpec string) (Interface, error)