queue

package
v0.3.70-rc-42e2cc7 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QueuesToAPI

func QueuesToAPI(queues []Queue) []*api.Queue

Types

type CreateAPI

type CreateAPI func(Queue) error

func Create

func Create(getConnectionDetails client.ConnectionDetails) CreateAPI

type DeleteAPI

type DeleteAPI func(string) error

func Delete

func Delete(getConnectionDetails client.ConnectionDetails) DeleteAPI

type GetInfoAPI

type GetInfoAPI func(string) (*api.QueueInfo, error)

func GetInfo

func GetInfo(getConnectionDetails client.ConnectionDetails) GetInfoAPI

type PermissionSubject

type PermissionSubject struct {
	Kind PermissionSubjectKind `json:"kind"`
	Name string                `json:"name"`
}

type PermissionSubjectKind

type PermissionSubjectKind string
const (
	PermissionSubjectKindGroup PermissionSubjectKind = "Group"
	PermissionSubjectKindUser  PermissionSubjectKind = "User"
)

func NewPermissionSubjectKind

func NewPermissionSubjectKind(in string) (PermissionSubjectKind, error)

NewPermissionSubjectKind returns PermissionSubjectKind from input string. If input string doesn't match one of the allowed kind values ["Group", "User"] error is returned.

func (PermissionSubjectKind) Generate

func (kind PermissionSubjectKind) Generate(rand *rand.Rand, size int) reflect.Value

Generate is implementation of https://pkg.go.dev/testing/quick#Generator interface. This method is used for writing tests usign https://pkg.go.dev/testing/quick package

func (*PermissionSubjectKind) UnmarshalJSON

func (kind *PermissionSubjectKind) UnmarshalJSON(data []byte) error

UnmarshalJSON is implementation of https://pkg.go.dev/encoding/json#Unmarshaler interface.

type PermissionSubjects

type PermissionSubjects []PermissionSubject

func NewPermissionSubjects

func NewPermissionSubjects(subjects []*api.Queue_Permissions_Subject) (PermissionSubjects, error)

NewPermissionSibjects returns PermissionSubjects using the subjects values. If any of the subjects has an invalid subject kind an error is returned.

func NewPermissionSubjectsFromOwners

func NewPermissionSubjectsFromOwners(users, groups []string) PermissionSubjects

NewPermissionSubjectsFromOwners creates Subjects from user and group owners. Subjects will have User subjects that contains all users specified in users parameter and Group subjects that contains all groups specified in groups parameter. This function is used for backward compatibility when permission subjects didn't exist and only user and group owners could be associated with the queues.

type PermissionVerb

type PermissionVerb string
const (
	PermissionVerbSubmit       PermissionVerb = "submit"
	PermissionVerbCancel       PermissionVerb = "cancel"
	PermissionVerbReprioritize PermissionVerb = "reprioritize"
	PermissionVerbWatch        PermissionVerb = "watch"
)

func NewPermissionVerb

func NewPermissionVerb(in string) (PermissionVerb, error)

NewPermissionVerb returns PermissionVerb from input string. If input string doesn't match one of allowed verb values ["submit", "cancel", "reprioritize", "watch"], and error is returned.

func (PermissionVerb) Generate

func (verb PermissionVerb) Generate(rand *rand.Rand, size int) reflect.Value

Generate is implementation of https://pkg.go.dev/testing/quick#Generator interface. This method is used for writing tests usign https://pkg.go.dev/testing/quick package

func (*PermissionVerb) UnmarshalJSON

func (verb *PermissionVerb) UnmarshalJSON(data []byte) error

UnmarshalJSON is implementation of https://pkg.go.dev/encoding/json#Unmarshaler interface.

type PermissionVerbs

type PermissionVerbs []PermissionVerb

func AllPermissionVerbs

func AllPermissionVerbs() PermissionVerbs

AllPermissionVerbs returns PermissionsVerbs containing all PermissionVerb values

func NewPermissionVerbs

func NewPermissionVerbs(verbs []string) (PermissionVerbs, error)

NewPermissionVerbs returns PermissionVerbs from string slice. Every string from slice is transformed into PermissionVerb. Error is returned if a string cannot be transformed to PermissionVerb.

type Permissions

type Permissions struct {
	Subjects PermissionSubjects `json:"subjects"`
	Verbs    PermissionVerbs    `json:"verbs"`
}

Permissions specifies the list of subjects that are allowed to perform queue operations specified by the list of verbs.

func NewPermissions

func NewPermissions(perm *api.Queue_Permissions) (Permissions, error)

NewPermissions returns Permissions from *api.Queue_Permissions. An error is returned if subjects/verbs can't be generated from *api.Queue_Permissions.Subjects/*api.Queue_Permissions.Verbs

func NewPermissionsFromOwners

func NewPermissionsFromOwners(users, groups []string) Permissions

NewPermissionsFromOwners creates Permissions from user and group owners. Permissions will have User subjects that contains all users specified in users parameter and Group subjects that contains all groups specified in groups parameter. Permissions will also include all currently supported verbs (effectively emulating old user's and group's owner permissions). This function is used for backward compatibility when permissions didn't exist and only user and group owners could perform queue operations.

func (Permissions) ToAPI

func (p Permissions) ToAPI() *api.Queue_Permissions

ToAPI converts Permissions to *api.Queue_Permissions.

type PriorityFactor

type PriorityFactor float64

func NewPriorityFactor

func NewPriorityFactor(in float64) (PriorityFactor, error)

NewPriorityFactor return PriorityFactor using the value of in. If in value is lower than 1.0 an error is returned.

func (PriorityFactor) Generate

func (f PriorityFactor) Generate(rand *rand.Rand, size int) reflect.Value

Generate is implementation of https://pkg.go.dev/testing/quick#Generator interface. This method is used for writing tests usign https://pkg.go.dev/testing/quick package

func (*PriorityFactor) UnmarshalJSON

func (f *PriorityFactor) UnmarshalJSON(data []byte) error

UnmarshalJSON is implementation of https://pkg.go.dev/encoding/json#Unmarshaler interface.

type Queue

type Queue struct {
	Name           string         `json:"name"`
	Permissions    []Permissions  `json:"permissions"`
	PriorityFactor PriorityFactor `json:"priorityFactor"`
	ResourceLimits ResourceLimits `json:"resourceLimits"`
}

func NewQueue

func NewQueue(in *api.Queue) (Queue, error)

NewQueue returnes new Queue using the in parameter. Error is returned if any of the queue fields has corresponding value in in that is invalid.

func (Queue) HasPermission

func (q Queue) HasPermission(inputSubject PermissionSubject, inputVerb PermissionVerb) bool

HasPermission returns true if the inputSubject is allowed to peform a queue operation specified by inputVerb parameter, otherwise returns false

func (Queue) ToAPI

func (q Queue) ToAPI() *api.Queue

ToAPI transforms Queue to *api.Queue structure

type ResourceLimit

type ResourceLimit float64

func NewResourceLimit

func NewResourceLimit(in float64) (ResourceLimit, error)

NewResourceLimit return ResourceLimit using the value of in. If in value is not in [0, 1] range an error is returned.

func (ResourceLimit) Generate

func (ResourceLimit) Generate(rand *rand.Rand, size int) reflect.Value

Generate is implementation of https://pkg.go.dev/testing/quick#Generator interface. This method is used for writing tests usign https://pkg.go.dev/testing/quick package

func (*ResourceLimit) UnmarshalJSON

func (rl *ResourceLimit) UnmarshalJSON(data []byte) error

UnmarshalJSON is implementation of https://pkg.go.dev/encoding/json#Unmarshaler interface.

type ResourceLimits

type ResourceLimits map[ResourceName]ResourceLimit

func NewResourceLimits

func NewResourceLimits(in map[string]float64) (ResourceLimits, error)

NewResourceLimits return ResourceLimits using the value of in. If any of the map values is not successfully converted to ResourceLimit an error is returned.

type ResourceName

type ResourceName string
const (
	ResourceNameCPU    ResourceName = "cpu"
	ResourceNameMemory ResourceName = "memory"
)

func NewResourceName

func NewResourceName(in string) (ResourceName, error)

NewResourceName return ResourceName using the value of in. If in value is not one of: "cpu", "memory" an error is returned.

func (ResourceName) Generate

func (ResourceName) Generate(rand *rand.Rand, size int) reflect.Value

Generate is implementation of https://pkg.go.dev/testing/quick#Generator interface. This method is used for writing tests usign https://pkg.go.dev/testing/quick package

func (*ResourceName) UnmarshalJSON

func (rn *ResourceName) UnmarshalJSON(data []byte) error

UnmarshalJSON is implementation of https://pkg.go.dev/encoding/json#Unmarshaler interface.

type UpdateAPI

type UpdateAPI func(queue Queue) error

func Update

func Update(getConnectionDetails client.ConnectionDetails) UpdateAPI

Jump to

Keyboard shortcuts

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