handler

package
v0.0.0-...-9f0065b Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: MIT Imports: 32 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PathProject is the top-leve directory in which directories of active projects are located.
	PathProject string = "/project"

	// QueueSetProject is the queue name for setting project resources.
	QueueSetProject string = "tasks.setProject"

	// QueueSetUser is the queue name for setting user resources.
	QueueSetUser string = "tasks.setUser"

	// DefaultHomeStorageSystem is the name of the default storage system used for user's home directory
	DefaultHomeStorageSystem = "netapp"
)
View Source
var (
	// NotImplementedError indicates the implementation of the handler is not implemented yet.
	NotImplementedError int64 = 100

	// RoleSettingError indicates error when setting the Role/ACL on the underlying filer.
	RoleSettingError int64 = 101

	// RoleGettingError indicates error when getting the Role/ACL from the underlying filer.
	RoleGettingError int64 = 102

	// QuotaGettingError indicates error when getting the quota limitation and usage from the underlying filer.
	QuotaGettingError int64 = 103

	// UserLookupError indicates error when looking up the user in the system.
	UserLookupError int64 = 104

	// MemberOfGettingError indicates error when looking up user's membership on all active projects.
	MemberOfGettingError int64 = 105

	// TaskQueueError indicates the request is failed to be added to the task queue for resource setting.
	TaskQueueError int64 = 106
)

Error code definitions.

Functions

func CreateProject

func CreateProject(ctx context.Context, bok *bokchoy.Bokchoy) func(params operations.PostProjectsParams, principle *models.Principle) middleware.Responder

CreateProject handles the project creation on filer by formulating it into an. asynchronous task.

task configuration: - canceled if running more than 12 hours. - no retry. - result is kept for 7 days.

func CreateUserResource

func CreateUserResource(ctx context.Context, bok *bokchoy.Bokchoy) func(params operations.PostUsersParams, principle *models.Principle) middleware.Responder

CreateUserResource handles the request for creating user home space on the filer by formulating the request into a asynchronous task.

task configuration: - canceled if running more than 1 hour. - no retry. - result is kept for 7 days.

func GetMetrics

GetMetrics handles the metrics request with the Prometheus handler

func GetPing

func GetPing(cfg config.Configuration) func(params operations.GetPingParams, principle *models.Principle) middleware.Responder

GetPing returns dummy string for health check, including the authentication.

func GetProjectResource

func GetProjectResource(cache *ProjectResourceCache) func(params operations.GetProjectsIDParams) middleware.Responder

GetProjectResource implements retrival of project resource (i.e. storage and members).

func GetProjects

func GetProjects(cache *ProjectResourceCache) func(params operations.GetProjectsParams) middleware.Responder

GetProjects implements retrival of resources of all projects implemented on the filer, under path of `handler.PathProject`.

func GetTask

GetTask retrieves task status.

func GetUserResource

func GetUserResource(ucache *UserResourceCache, pcache *ProjectResourceCache) func(params operations.GetUsersIDParams) middleware.Responder

GetUserResource implements retrival of file resource for a user (i.e. storage).

func GetUsers

GetUsers implements retrival of resources of all system users with UID >= 1000.

func NewCustomResponder

func NewCustomResponder(r *http.Request, h http.Handler) middleware.Responder

func UpdateProject

func UpdateProject(ctx context.Context, bok *bokchoy.Bokchoy) func(params operations.PatchProjectsIDParams, principle *models.Principle) middleware.Responder

UpdateProject implements the project update on filer systems. Those updates can be one of the following:

- update project quota. - set project members.

The corresponding project directory on the filer should exist in advance.

task configuration: - canceled if running more than 12 hours. - no retry. - result is kept for 7 days.

func UpdateUserResource

func UpdateUserResource(ctx context.Context, bok *bokchoy.Bokchoy) func(params operations.PatchUsersIDParams, principle *models.Principle) middleware.Responder

UpdateUserResource handles the request for updating user home space quota on the filer by formulating the request into a asynchronous task.

task configuration: - canceled if running more than 1 hour. - no retry. - result is kept for 7 days.

Types

type CustomResponder

type CustomResponder func(http.ResponseWriter, runtime.Producer)

This trick of integrating promhttp handler with swagger server is taken from the blog: https://www.kaznacheev.me/posts/en/go_swagger_tricks/

func (CustomResponder) WriteResponse

func (c CustomResponder) WriteResponse(w http.ResponseWriter, p runtime.Producer)

type ProjectResourceCache

type ProjectResourceCache struct {

	// Config is the general API server configuration.
	Config config.Configuration

	// Context is the API server context.
	Context context.Context

	// Notifier is the redis channel subscription via which
	// a refresh on a given project can be triggered on-demand.
	Notifier <-chan *redis.Message

	// IsStopped indicates whether the cache service is stopped.
	IsStopped bool
	// contains filtered or unexported fields
}

ProjectResourceCache is an in-memory store for caching `projectResource` of all existing projects on the filer.

func (*ProjectResourceCache) Init

func (c *ProjectResourceCache) Init()

init initializes the cache with first reload.

type ResponseError

type ResponseError struct {
	// contains filtered or unexported fields
}

ResponseError is an internal error type for the API handler function to determine which response error should be returned to the API client.

func (*ResponseError) Error

func (e *ResponseError) Error() string

type UserResourceCache

type UserResourceCache struct {

	// Config is the general API server configuration.
	Config config.Configuration

	// Context is the API server context.
	Context context.Context

	// Notifier is the redis channel subscription via which
	// a refresh on a given project can be triggered on-demand.
	Notifier <-chan *redis.Message

	// IsStopped indicates whether the cache service is stopped.
	IsStopped bool
	// contains filtered or unexported fields
}

UserResourceCache is an in-memory store for caching `projectResource` of all existing projects on the filer.

func (*UserResourceCache) Init

func (c *UserResourceCache) Init()

init initializes the cache with first reload.

Jump to

Keyboard shortcuts

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