client

package
v1.1.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: Apache-2.0 Imports: 19 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultWatchInterval time.Duration = 30 * time.Second
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client interface {
	Reader
	Writer
	Informers

	SetServer(server string)
	GetServer() string
	SetToken(token string)
	GetToken() string
}

Client knows how to perform CRUD operations on Slurm objects.

func NewClient

func NewClient(config *Config, opts ...ClientOption) (Client, error)

NewClient initializes a client.

type ClientOption

type ClientOption interface {
	// ApplyToCreate applies this configuration to the given client options.
	ApplyToClient(*ClientOptions)
}

ClientOption is some configuration that modifies options for the client.

type ClientOptions

type ClientOptions struct {
	// EnableFor indicates the list of resources for the informer to ensure.
	EnableFor []object.Object

	// DisableFor indicates the list of resources for the informer to ignore.
	DisableFor []object.Object

	// CacheSyncPeriod is the time to wait before updating the cache
	CacheSyncPeriod time.Duration
}

ClientOptions contains options for creating a client to make requests to Slurm.

func (*ClientOptions) ApplyOptions

func (o *ClientOptions) ApplyOptions(opts []ClientOption) *ClientOptions

ApplyOptions applies the given create options on these options, and then returns itself (for convenient chaining).

func (*ClientOptions) ApplyToClient

func (o *ClientOptions) ApplyToClient(co *ClientOptions)

ApplyToClient implements ClientOption.

type Config

type Config struct {
	// The server with port (e.g. `http://localhost:8080/`).
	// +required
	Server string

	// The Slurm JWT token for authentication.
	// +required
	AuthToken string

	// HTTPClient is the HTTP client to use for requests.
	HTTPClient *http.Client
}

Config holds the common attributes that can be passed to a Slurm client on initialization.

type CreateOption

type CreateOption interface {
	// ApplyToCreate applies this configuration to the given create options.
	ApplyToCreate(*CreateOptions)
}

CreateOption is some configuration that modifies options for a create request.

type CreateOptions

type CreateOptions struct {
}

CreateOptions contains options for create requests. It's generally a subset of metav1.CreateOptions.

func (*CreateOptions) ApplyOptions

func (o *CreateOptions) ApplyOptions(opts []CreateOption) *CreateOptions

ApplyOptions applies the given create options on these options, and then returns itself (for convenient chaining).

func (*CreateOptions) ApplyToCreate

func (o *CreateOptions) ApplyToCreate(co *CreateOptions)

ApplyToCreate implements CreateOption.

type DeleteOption

type DeleteOption interface {
	// ApplyToDelete applies this configuration to the given delete options.
	ApplyToDelete(*DeleteOptions)
}

DeleteOption is some configuration that modifies options for a delete request.

type DeleteOptions

type DeleteOptions struct {
}

DeleteOptions contains options for delete requests. It's generally a subset of metav1.DeleteOptions.

func (*DeleteOptions) ApplyOptions

func (o *DeleteOptions) ApplyOptions(opts []DeleteOption) *DeleteOptions

ApplyOptions applies the given delete options on these options, and then returns itself (for convenient chaining).

func (*DeleteOptions) ApplyToDelete

func (o *DeleteOptions) ApplyToDelete(do *DeleteOptions)

ApplyToDelete implements DeleteOption.

type GetOption

type GetOption interface {
	// ApplyToGet applies this configuration to the given get options.
	ApplyToGet(*GetOptions)
}

GetOption is some configuration that modifies options for a get request.

type GetOptions

type GetOptions struct {
	// SkipCache indicates not to use cache when fetching data.
	SkipCache bool

	// RefreshCache indicates to refresh the cache before reading from it.
	RefreshCache bool

	// WaitRefreshCache indicates to wait for the next cache refresh before reading from it.
	WaitRefreshCache bool
}

GetOptions contains options for get operation. Now it only has a Raw field, with support for specific resourceVersion.

func (*GetOptions) ApplyOptions

func (o *GetOptions) ApplyOptions(opts []GetOption) *GetOptions

ApplyOptions applies the given get options on these options, and then returns itself (for convenient chaining).

func (*GetOptions) ApplyToGet

func (o *GetOptions) ApplyToGet(lo *GetOptions)

ApplyToGet implements GetOption for GetOptions.

type Informer

type Informer interface {
	// SetEventHandler sets an event handler to the informer. When cache changes,
	// event handlers will trigger.
	SetEventHandler(handler cache.ResourceEventHandler)

	// UnsetEventHandler unsets the event handler of the informer.
	UnsetEventHandler()

	// HasSynced return true if the informers underlying store has synced.
	HasSynced() (bool, error)

	// HasStarted return true if the informers underlying store has been started.
	HasStarted() bool

	// Run starts and runs the informer, returning after it stops.
	// The informer will be stopped when stopCh is closed.
	Run(stopCh <-chan struct{})
}

Informer - informer allows you interact with the underlying informer.

type InformerCache

type InformerCache interface {
	Informer
	Reader
}

type Informers

type Informers interface {
	// GetInformer fetches or constructs an informer for the given objectType that corresponds to the
	// non-list version of the resource.
	GetInformer(objectType object.ObjectType) InformerCache

	// Start runs all the informers known to this cache until the context is closed.
	// It blocks.
	Start(ctx context.Context)

	// Stop runs all the informers known to this cache until the context is closed.
	// It blocks.
	Stop()
}

Informers knows how to create or fetch informers for different Objects. It's safe to call GetInformer from multiple threads.

type ListOption

type ListOption interface {
	// ApplyToList applies this configuration to the given list options.
	ApplyToList(*ListOptions)
}

ListOption is some configuration that modifies options for a list request.

type ListOptions

type ListOptions struct {
	// SkipCache indicates not to use cache when fetching data.
	SkipCache bool

	// RefreshCache indicates to refresh the cache before reading from it.
	RefreshCache bool

	// WaitRefreshCache indicates to wait for the next cache refresh before reading from it.
	WaitRefreshCache bool
}

ListOptions contains options for limiting or filtering results. It's generally a subset of metav1.ListOptions, with support for pre-parsed selectors (since generally, selectors will be executed against the cache).

func (*ListOptions) ApplyOptions

func (o *ListOptions) ApplyOptions(opts []ListOption) *ListOptions

ApplyOptions applies the given list options on these options, and then returns itself (for convenient chaining).

func (*ListOptions) ApplyToList

func (o *ListOptions) ApplyToList(lo *ListOptions)

ApplyToList implements ListOption for ListOptions.

type ObjectKey

type ObjectKey = object.ObjectKey

ObjectKey identifies a Slurm Object.

func ObjectKeyFromObject

func ObjectKeyFromObject(obj object.Object) ObjectKey

ObjectKeyFromObject returns the ObjectKey given a object.Object.

type Reader

type Reader interface {
	// Get retrieves an obj for the given object key from the Slurm Cluster.
	// obj must be a struct pointer so that obj can be updated with the response
	// returned by the Server.
	Get(ctx context.Context, key object.ObjectKey, obj object.Object, opts ...GetOption) error

	// List retrieves list of objects for a given namespace and list options. On a
	// successful call, Items field in the list will be populated with the
	// result returned from the server.
	List(ctx context.Context, list object.ObjectList, opts ...ListOption) error
}

Reader knows how to read and list Slurm objects.

type UpdateOption

type UpdateOption interface {
	// ApplyToUpdate applies this configuration to the given update options.
	ApplyToUpdate(*UpdateOptions)
}

UpdateOption is some configuration that modifies options for a update request.

type UpdateOptions

type UpdateOptions struct {
}

UpdateOptions contains options for create requests.

func (*UpdateOptions) ApplyOptions

func (o *UpdateOptions) ApplyOptions(opts []UpdateOption) *UpdateOptions

ApplyOptions applies the given update options on these options, and then returns itself (for convenient chaining).

func (*UpdateOptions) ApplyToUpdate

func (o *UpdateOptions) ApplyToUpdate(uo *UpdateOptions)

ApplyToUpdate implements UpdateOption.

type Writer

type Writer interface {
	// Create saves the object obj in the Slurm cluster. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Create(ctx context.Context, obj object.Object, req any, opts ...CreateOption) error

	// Update updates the given obj in the Slurm cluster. obj must be a
	// struct pointer so that obj can be updated with the content returned by the Server.
	Update(ctx context.Context, obj object.Object, req any, opts ...UpdateOption) error

	// Delete deletes the given obj from Slurm cluster.
	Delete(ctx context.Context, obj object.Object, opts ...DeleteOption) error
}

Writer knows how to create, delete, and update Slurm objects.

Jump to

Keyboard shortcuts

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