github.com/castai/kvisor@v1.7.1-0.20240516114728-b3572a2607b5/cmd/controller/state/types.go (about)

     1  package state
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  )
     7  
     8  type PodsStats struct {
     9  	ContainerStatuses []ContainerStatusStats `json:"containerStatuses"`
    10  	Phases            []PodPhaseStats        `json:"phases"`
    11  	TrafficTypes      []TrafficTypeStats     `json:"trafficTypes"`
    12  }
    13  
    14  type PodPhaseStats struct {
    15  	Value string `json:"value"`
    16  	Text  string `json:"text"`
    17  	Count int    `json:"count"`
    18  }
    19  
    20  type TrafficTypeStats struct {
    21  	Value string `json:"value"`
    22  	Text  string `json:"text"`
    23  	Count int    `json:"count"`
    24  }
    25  
    26  type ContainerStatusStats struct {
    27  	Value string `json:"value"`
    28  	Text  string `json:"text"`
    29  	Count int    `json:"count"`
    30  }
    31  
    32  type TrafficType string
    33  
    34  const (
    35  	TrafficTypeInternet     TrafficType = "internet"
    36  	TrafficTypePrivate      TrafficType = "private"
    37  	TrafficTypeControlPlane TrafficType = "control_plane"
    38  	TrafficTypeCrossZone    TrafficType = "cross_zone"
    39  	TrafficTypeWorkload     TrafficType = "workload"
    40  	TrafficTypeService      TrafficType = "service"
    41  )
    42  
    43  type FlowsFilter struct {
    44  	Namespaces []string `json:"namespaces"`
    45  	IDs        []string `json:"ids"`
    46  	// If set to true filtering by IDs will try to filter by WorkloadKey or ID.
    47  	TryWorkloadIDs bool `json:"-"`
    48  }
    49  
    50  type Namespace struct {
    51  	Name string `json:"name"`
    52  }
    53  
    54  func sleep(ctx context.Context, d time.Duration) {
    55  	timeout := time.NewTimer(d)
    56  	defer timeout.Stop()
    57  	select {
    58  	case <-ctx.Done():
    59  		return
    60  	case <-timeout.C:
    61  		return
    62  	}
    63  }