progress

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2020 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ProgressPath = "~/.kubesim/progress.json"

ProgressPath is the path to the progress file

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPHandler

type HTTPHandler struct {
	StateProvider StateProvider
	Logger        *logrus.Logger
}

HTTPHandler processes HTTP requests received on the SSH reverse tunnel recording the users progress

func NewHTTPHandler

func NewHTTPHandler(sp StateProvider, logger *logrus.Logger) HTTPHandler

NewHTTPHandler constructs a new HTTPHandler instance

func (HTTPHandler) ServeHTTP

func (hh HTTPHandler) ServeHTTP(rw http.ResponseWriter, req *http.Request)

ServeHTTP handles HTTP requests to record the progress a user has made on a scenario

type LocalStateProvider

type LocalStateProvider struct {
	Logger *logrus.Logger
}

LocalStateProvider persists and retrieves a user's progress to the local ~/.kubesim folder

func NewLocalStateProvider

func NewLocalStateProvider(logger *logrus.Logger) LocalStateProvider

NewLocalStateProvider returns an instance of LocalStateProvider

func (LocalStateProvider) GetLogger

func (lsp LocalStateProvider) GetLogger() *logrus.Logger

GetLogger returns the state provider's logger

func (LocalStateProvider) GetProgress

func (lsp LocalStateProvider) GetProgress(scenario string) (*ScenarioProgress, error)

GetProgress retrieves the user's progress for the provided scenario

func (LocalStateProvider) SaveProgress

func (lsp LocalStateProvider) SaveProgress(update ScenarioProgress) error

SaveProgress persists the user's progress on a scenairio to the local ~/.kubesim folder

type Progress

type Progress struct {
	Scenarios []ScenarioProgress `json:"scenarioProgress"`
}

Progress represents a user's progress for all scenarios they have launched

type ScenarioProgress

type ScenarioProgress struct {
	Name        string         `json:"name"`
	CurrentTask *int           `json:"currentTask"`
	Tasks       []TaskProgress `json:"tasks"`
}

ScenarioProgress represents a user's progress on a particular scenario

type StateProvider

type StateProvider interface {
	GetLogger() *logrus.Logger
	GetProgress(scenario string) (*ScenarioProgress, error)
	SaveProgress(p ScenarioProgress) error
}

StateProvider defines the contract for retrieving and persisting a user's progress

type TaskProgress

type TaskProgress struct {
	ID             int  `json:"id"`
	LastHintIndex  *int `json:"lastHintIndex"`
	Score          *int `json:"score"`
	ScoringSkipped bool `json:"scoringSkipped"`
}

TaskProgress represents a user's progress on a particular task

Jump to

Keyboard shortcuts

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