sessions

package
v0.0.0-...-df84525 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2019 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateSession

func CreateSession(c *gin.Context)

CreateSession handles the POST method to create a new session.

func DeleteSession

func DeleteSession(c *gin.Context)

DeleteSession handles the DELETE method to remove an existing session.

func GetSession

func GetSession(c *gin.Context)

GetSession handles the GET method to fetch a session data.

func PullAvailableImages

func PullAvailableImages() *apierrors.APIError

func Routes

func Routes(route *gin.Engine)

Routes configures URL mapping for sessions.

func RunCleaner

func RunCleaner()

RunCleaner ticks for configured time steps for deleting older existing sessions.

Types

type Container

type Container struct {
	ID           string       `json:"id"`
	Distribution Distribution `json:"distribution"`
	Tag          string       `json:"tag"`
	URL          string       `json:"url"`
	CreatedAt    time.Time    `json:"created_at"`
	DeletedAt    *time.Time   `json:"deleted_at,omitempty"`
}

func FetchSession

func FetchSession(id string) (*Container, *apierrors.APIError)

FetchSession returns the session data for given session ID, or an error if it fails to fetch.

func NewSession

func NewSession(od *OSDistribution) (*Container, *apierrors.APIError)

NewSession builds a new container instance and returns its data associated or an error if it fails.

func RemoveSession

func RemoveSession(id string) (*Container, *apierrors.APIError)

RemoveSession terminates and removes all data about given session ID. It returns its data at the delete moment or an error if the operation fails.

func (Container) HasExpired

func (c Container) HasExpired(d time.Duration) bool

type Distribution

type Distribution string

Distribution refers to Linux distributions.

type DockerClient

type DockerClient interface {
	Pull(distribution Distribution, tag string) *apierrors.APIError
	Create(distribution Distribution, tag string, cpus, memory int64, hostIP string, hostPort int) (*Container, *apierrors.APIError)
	Get(id string) (*Container, *apierrors.APIError)
	Destroy(id string) *apierrors.APIError
	List() ([]Container, *apierrors.APIError)
	Context() context.Context
}

func NewDockerClient

func NewDockerClient() DockerClient

type OSDistribution

type OSDistribution struct {
	Distribution Distribution `json:"distribution"`
	Tag          string       `json:"tag"`
}

OSDistribution responds to the required data needed to create a new session.

func (*OSDistribution) UnmarshalJSON

func (od *OSDistribution) UnmarshalJSON(data []byte) error

UnmarshalJSON is a custom implementation for unmarshalling OSDistribution in order to check valid distribution name.

Jump to

Keyboard shortcuts

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