Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for NewFromSnapshot (0.27 sec)

  1. pkg/registry/core/service/portallocator/allocator.go

    	return New(pr, func(max int, rangeSpec string, offset int) (allocator.Interface, error) {
    		return allocator.NewAllocationMapWithOffset(max, rangeSpec, offset), nil
    	})
    }
    
    // NewFromSnapshot allocates a PortAllocator and initializes it from a snapshot.
    func NewFromSnapshot(snap *api.RangeAllocation) (*PortAllocator, error) {
    	pr, err := net.ParsePortRange(snap.Range)
    	if err != nil {
    		return nil, err
    	}
    	r, err := NewInMemory(*pr)
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed May 08 07:15:02 UTC 2024
    - 7.4K bytes
    - Viewed (0)
  2. pkg/registry/core/service/portallocator/allocator_test.go

    		if err != nil {
    			t.Fatal(err)
    		}
    		allocated = append(allocated, p)
    	}
    
    	snapshot := api.RangeAllocation{}
    	if err = r.Snapshot(&snapshot); err != nil {
    		t.Fatal(err)
    	}
    
    	r, err = NewFromSnapshot(&snapshot)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	if x := r.Free(); x != 51 {
    		t.Fatalf("expected 51 free ports, got %d", x)
    	}
    	if x := r.Used(); x != 50 {
    Registered: Sat Jun 15 01:39:40 UTC 2024
    - Last Modified: Wed May 08 07:15:02 UTC 2024
    - 14K bytes
    - Viewed (0)
Back to top