service

package module
v0.0.0-...-b1c2c33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AllLoadBalancers = iota
	InternalLoadBalancers
	ExternalLoadBalancers
)

Variables

View Source
var (
	ErrorInvalidChannel    error = errors.New("invalid channel provided")
	ErrorInvalidOptions    error = errors.New("invalid options provided")
	ErrorInvalidWorkerPool error = errors.New("invalid worker pool")
	ErrorCreatingPool      error = errors.New("cannot create worker pool")
	ErrorCannotSubmitTask  error = errors.New("cannot submit task to worker pool")
)

Functions

This section is empty.

Types

type GetResults

type GetResults struct {
	Services []*Service
	Errors   []error
}

func GetServices

func GetServices(ctx context.Context, clientset kubernetes.Interface, opts ...RetrieveOption) (*GetResults, error)

type LoadBalancerType

type LoadBalancerType int

type RetrieveOption

type RetrieveOption func(*RetrieveOptions) error

func WithCompletionChannel

func WithCompletionChannel(completionChan chan<- struct{}) RetrieveOption

Signal completion to this channel.

By default, the retriever will close the channel you provide via `WithResultChannel` when its task is complete. This option will override this behavior by keeping that channel alive, and instead signal completion to this other channel by sending an empty array. This is useful in case you are re-using the channel for other purposes or when you are looping through `select`.

If not used in conjunction to `WithResultChannel`, this option will have no effect.

func WithExternalLoadBalancers

func WithExternalLoadBalancers() RetrieveOption

func WithExternalNames

func WithExternalNames() RetrieveOption

func WithInternalLoadBalancers

func WithInternalLoadBalancers() RetrieveOption

func WithLabel

func WithLabel(key, value string) RetrieveOption

func WithLabels

func WithLabels(labels map[string]string) RetrieveOption

func WithMaxWorkers

func WithMaxWorkers(workers uint) RetrieveOption

Set the maximum number of workers, or concurrent tasks.

By default, retrievers will try to maximize concurrency and prioritize non-blocking operations, especially in case many regions need to be queried. This option sets a limit on the concurrent tasks that can be performed.

This option will have no effect in case you are providing you own worker pool, in which case you will have to limit concurrency on your own.

Providing `0` will make it use the default value (100).

func WithNamespaces

func WithNamespaces(namespaces ...string) RetrieveOption

func WithNodePorts

func WithNodePorts() RetrieveOption

func WithResultChannel

func WithResultChannel(servicesChan chan<- *Service) RetrieveOption

Send results to this channel. The retriever will send clusters to this channel as soon as it finds them.

Once done, the retriever will close this channel to signal that there is no more data to send.

Make sure your channel is buffered before sending it to the retriever to avoid performance penalties in case you expect many clusters to be found.

func WithWorkerPool

func WithWorkerPool(workerPool *ants.Pool) RetrieveOption

Sets a custom worker pool.

This is useful in case you are already using a worker pool for your own purposes and want to re-use your idle workers to perform these tasks.

type RetrieveOptions

type RetrieveOptions struct {
	NodePorts        bool
	ExternalNames    bool
	Namespaces       map[string]bool
	LoadBalancerType LoadBalancerType
	Labels           map[string]string
	MaxWorkers       uint
	WorkerPool       *ants.Pool
	ServicesChan     chan<- *Service
	CompletionChan   chan<- struct{}
}

type Service

type Service struct {
	Name           string
	Namespace      string
	Type           v1.ServiceType
	HostNames      []string
	IPs            []string
	Ports          []uint32
	OriginalObject v1.Service
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL