domain

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package domain is a generated GoMock package.

Index

Constants

View Source
const SandboxAppService = 14

SandboxAppService is the Twine service ID for querying the app for things like routes, exec fns, ..and anything else that is set in code.

View Source
const SandboxMigrateService = 13

SandboxMigrateService is the Twine service ID for appspace migration

Variables

View Source
var ErrAppConfigNotFound = errors.New("App config json not found")

ErrAppConfigNotFound means the application config (dropapp.json) file was not found

View Source
var ErrAppVersionInUse = errors.New("app version in use")

ErrAppVersionInUse indicates the operation could not be performed on the app version because something (probably an appspace) depends on it

View Source
var ErrAppspaceLockedClosed = errors.New("appspace is locked closed")

ErrAppspaceLockedClosed the operation could not beperformed because the appspace is currently closed

View Source
var ErrNoRowsAffected = errors.New("no rows affected")

ErrNoRowsAffected indicates a no DB rows were affected

View Source
var ErrNoRowsInResultSet = errors.New("no rows in result set")

ErrNoRowsInResultSet indicates that no rows were found in db

View Source
var ErrTokenNotFound = errors.New("token not found")

ErrTokenNotFound is used when a token is ued to gain access to a process or to data. This error indicates that the token may have expired or it never existed

Functions

func CtxSessionID

func CtxSessionID(ctx context.Context) (string, bool)

CtxSessionID gets the authenticated user id from the context Second value is false if no auth user id

func CtxWithAppData

func CtxWithAppData(ctx context.Context, app App) context.Context

CtxWithAppData sets the app data that is solely relevant to the request

func CtxWithAppGetKey

func CtxWithAppGetKey(ctx context.Context, commitKey AppGetKey) context.Context

CtxWithAppGetKey sets the app get key on context

func CtxWithAppVersionData

func CtxWithAppVersionData(ctx context.Context, appVersion AppVersion) context.Context

CtxWithAppVersionData sets the app data that is solely relevant to the request

func CtxWithAppspaceData

func CtxWithAppspaceData(ctx context.Context, appspace Appspace) context.Context

CtxWithAppspaceData sets the appspace data that is solely relevant to the request

func CtxWithAppspaceUserData

func CtxWithAppspaceUserData(ctx context.Context, user AppspaceUser) context.Context

CtxWithAppspaceUserData sets the appspace data that is solely relevant to the request

func CtxWithAppspaceUserProxyID

func CtxWithAppspaceUserProxyID(ctx context.Context, proxyID ProxyID) context.Context

CtxWithAppspaceUserProxyID sets the appspace data that is solely relevant to the request

func CtxWithAuthUserID

func CtxWithAuthUserID(ctx context.Context, userID UserID) context.Context

CtxWithAuthUserID sets the authenticated user id on the context

func CtxWithSessionID

func CtxWithSessionID(ctx context.Context, sessionId string) context.Context

CtxWithSessionID sets the authenticated user id on the context

func CtxWithV0RouteConfig

func CtxWithV0RouteConfig(ctx context.Context, routeConfig V0AppRoute) context.Context

CtxWithRouteConfig sets the appspace route data for the request

Types

type APIVersion

type APIVersion int

APIVersion is the Dropserver API version that a dropserver app interacts with

type App

type App struct {
	OwnerID UserID `db:"owner_id"`
	AppID   AppID  `db:"app_id"`
	Name    string
	Created time.Time
}

App represents the data structure for an App.

func CtxAppData

func CtxAppData(ctx context.Context) (App, bool)

CtxAppData gets the app data that is solely relevant to the request

type AppFilesMetadata

type AppFilesMetadata struct {
	AppName         string                   `json:"name"`
	AppVersion      Version                  `json:"version"`
	APIVersion      APIVersion               `json:"api_version"`
	UserPermissions []AppspaceUserPermission `json:"user_permissions"` // this should be removed.
}

AppFilesMetadata containes metadata that can be gleaned from reading the application files This is going to evolve until it becomes data that comes from the sandbox.

type AppGetEvent

type AppGetEvent struct {
	Key   AppGetKey `json:"key"`
	Done  bool      `json:"done"`
	Error bool      `json:"error"`
	Step  string    `json:"step"`
}

AppGetEvent contains updates to an app getter process

type AppGetKey

type AppGetKey string

func CtxAppGetKey

func CtxAppGetKey(ctx context.Context) (AppGetKey, bool)

CtxAppGetKey gets the app processing commit key from context

type AppGetMeta

type AppGetMeta struct {
	Key             AppGetKey        `json:"key"`
	Schema          int              `json:"schema"`
	PrevVersion     Version          `json:"prev_version"`
	NextVersion     Version          `json:"next_version"`
	Errors          []string         `json:"errors"`
	VersionMetadata AppFilesMetadata `json:"version_metadata,omitempty"`
}

AppGetMeta has app version data and any errors found in it

type AppID

type AppID uint32

AppID is an application ID

type AppVersion

type AppVersion struct {
	AppID       AppID  `db:"app_id"`
	AppName     string `db:"app_name"`
	Version     Version
	APIVersion  APIVersion `db:"api"`
	Schema      int        `db:"schema"` // that is the schema for the app's own data
	Created     time.Time
	LocationKey string `db:"location_key"`
}

AppVersion represents a set of app files with a version

func CtxAppVersionData

func CtxAppVersionData(ctx context.Context) (AppVersion, bool)

CtxAppVersionData gets the app data that is solely relevant to the request

type Appspace

type Appspace struct {
	OwnerID     UserID     `db:"owner_id"`
	AppspaceID  AppspaceID `db:"appspace_id"`
	AppID       AppID      `db:"app_id"`
	AppVersion  Version    `db:"app_version"`
	DropID      string     `db:"dropid"`
	DomainName  string     `db:"domain_name"`
	Created     time.Time  `db:"created"`
	Paused      bool       `db:"paused"`
	LocationKey string     `db:"location_key"`
}

Appspace represents the data structure for App spaces.

func CtxAppspaceData

func CtxAppspaceData(ctx context.Context) (Appspace, bool)

CtxAppspaceData gets the appspace data that is solely relevant to the request

type AppspaceID

type AppspaceID uint32

AppspaceID is a unique ID for an appspace

type AppspaceMetaInfo

type AppspaceMetaInfo struct {
	Schema int
}

AppspaceMetaInfo is stored in the appspace meta db and represents the current state of the appspace's data

type AppspacePausedEvent

type AppspacePausedEvent struct {
	AppspaceID AppspaceID
	Paused     bool
}

AppspacePausedEvent is the payload for appspace paused event

type AppspaceRouteAuth

type AppspaceRouteAuth struct {
	//Allow is either "public", "authorized"
	Allow string `json:"allow"`
	// Permission that is required to access this route
	// An empty string means no specifc permission needed
	Permission string `json:"permission"`
}

AppspaceRouteAuth is a JSON friendly struct that contains description of auth paradigm for a route Will need a lot more than just type in the long run.

type AppspaceRouteConfig

type AppspaceRouteConfig struct {
	Methods []string             `json:"methods"`
	Path    string               `json:"path"`
	Auth    AppspaceRouteAuth    `json:"auth"`
	Handler AppspaceRouteHandler `json:"handler"`
}

AppspaceRouteConfig gives necessary data to handle an appspace route

type AppspaceRouteHandler

type AppspaceRouteHandler struct {
	Type     string `json:"type"`           // how can we validate that "type" is entered corrently?
	File     string `json:"file,omitempty"` // this is called "location" downstream. (but why?)
	Function string `json:"function,omitempty"`
	Path     string `json:"path,omitempty"`
}

AppspaceRouteHandler is a JSON friendly struct that describes the desired handling for the route

type AppspaceRouteHitEvent

type AppspaceRouteHitEvent struct {
	Timestamp     time.Time
	AppspaceID    AppspaceID
	Request       *http.Request
	V0RouteConfig *V0AppRoute // use generic app route, not versioned
	// Credentials presented by the requester
	// zero-values indicate credential not presented
	Credentials struct {
		ProxyID ProxyID
	}
	// Authorized: whether the route was authorized or not
	Authorized bool
	Status     int
}

AppspaceRouteHitEvent contains the route that was matched with the request Is this versioned or not? It would be easier if not. Or at least have basic data unversioned, and more details versioned?

type AppspaceRouteModels

type AppspaceRouteModels interface {
	GetV0(AppspaceID) V0RouteModel
}

AppspaceRouteModels returns models of the desired version

type AppspaceStatusEvent

type AppspaceStatusEvent struct {
	AppspaceID       AppspaceID `json:"appspace_id"`
	Paused           bool       `json:"paused"`
	TempPaused       bool       `json:"temp_paused"`
	TempPauseReason  string     `json:"temp_pause_reason"`
	AppspaceSchema   int        `json:"appspace_schema"`
	AppVersionSchema int        `json:"app_version_schema"`
	Problem          bool       `json:"problem"` // string? To hint at the problem?
}

AppspaceStatusEvent indicates readiness of appspace and the reason

type AppspaceUser

type AppspaceUser struct {
	AppspaceID  AppspaceID         `json:"appspace_id"`
	ProxyID     ProxyID            `json:"proxy_id"`
	AuthType    string             `json:"auth_type"`
	AuthID      string             `json:"auth_id"`
	DisplayName string             `json:"display_name"`
	Avatar      string             `json:"avatar"`
	Permissions []string           `json:"permissions"`
	Created     time.Time          `json:"created_dt"`
	LastSeen    nulltypes.NullTime `json:"last_seen"`
}

AppspaceUser identifies a user of an appspace Not sure we want this to have this form? Auth should be its own struct? TODO this is AppspaceUserV0

func CtxAppspaceUserData

func CtxAppspaceUserData(ctx context.Context) (AppspaceUser, bool)

CtxAppspaceUserData gets the appspace data that is solely relevant to the request

type AppspaceUserPermission

type AppspaceUserPermission struct {
	Key         string `json:"key"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

AppspaceUserPermission describes a permission that can be granted to a user, or via other means. The name and description are user-facing, the key is used internally.

type Authentication

type Authentication struct {
	Authenticated bool
	UserID        UserID
	AppspaceID    AppspaceID
	ProxyID       ProxyID // for appspace users (including owner)
	UserAccount   bool    // Tells whether this is for user account auth. Otherwise it's for appspace
	CookieID      string  // if there is a cookie
}

Authentication provides the authenticated data for a request OK, but this is confusing when you have auth for user admin stuff and auth for appspaces Proably need to separate those out, along with separate cookie tables, etc... Thinkn about the meaning of authentication... You're either a ds-host user (user id), or an appspace user proxy id or you have an api key ...which is all fine, but it means cookies have to be tweaked as well

type BadRestoreZip

type BadRestoreZip interface {
	Error() string
	MissingFiles() []string
	ZipFiles() []string
}

BadRestoreZip provides enough data to produce user-friendly errors when an appspace data archive is unusable

type CGroupData

type CGroupData struct {
	CpuUsec     int
	MemoryBytes int
	IOBytes     int
	IOs         int
}

type CGroupLimits added in v0.7.2

type CGroupLimits struct {
	MemoryHigh int
}

CGroupLimits specifies the limits to appply to sandboxes via cgroup controllers

type Contact

type Contact struct {
	UserID      UserID    `db:"user_id"`
	ContactID   ContactID `db:"contact_id"`
	Name        string    `db:"name"`
	DisplayName string    `db:"display_name"`
	Created     time.Time `db:"created"`
}

Contact represents a user's contact Q: where how when do we attach other props lige appspace use and auth methods?

type ContactID

type ContactID uint32

ContactID is an ID for a user's contact

type Cookie struct {
	CookieID string    `db:"cookie_id"`
	Expires  time.Time `db:"expires"`

	// UserID is confusing. is it contact id in case of appspace?
	// what is it for owner of appspace?
	UserID UserID `db:"user_id"`

	// UserAccount indicates whether this cookie is for the user's account management
	UserAccount bool `db:"user_account"`

	// AppspaceID is the appspace that the cookie can authorize
	// It's mutually exclusive with UserAccount.
	AppspaceID AppspaceID `db:"appspace_id"`

	// ProxyID is for appspace users (including owner id)
	ProxyID ProxyID `db:"proxy_id"`

	// DomainName is the domain that the cookie is set to
	// kind of redundant but simplifies sending cookie with updated expiration
	DomainName string `db:"domain"`
}

Cookie represents the server-side representation of a stored cookie Might be called DBCookie to differentiate from thing that came from client?

type DB

type DB struct {
	Handle *sqlx.DB
}

DB is the global host database handler OK, but it does not need to be wrapped in a struct!

type DomainCheckResult

type DomainCheckResult struct {
	Valid     bool   `json:"valid"`
	Available bool   `json:"available"`
	Message   string `json:"message"`
}

DomainCheckResult is the result of checking for a domain and subdomain's availability and validity for a particular purpose.

type DomainData

type DomainData struct {
	DomainName                string `json:"domain_name"`
	UserOwned                 bool   `json:"user_owned"`
	ForAppspace               bool   `json:"for_appspace"`
	AppspaceSubdomainRequired bool   `json:"appspace_subdomain_required"`
	ForDropID                 bool   `json:"for_dropid"`
	DropIDSubdomainAllowed    bool   `json:"dropid_subdomain_allowed"`
}

DomainData tells how a domain name can be used

type DropID

type DropID struct {
	UserID      UserID    `db:"user_id" json:"user_id"`
	Handle      string    `db:"handle" json:"handle" validate:"nonzero,max=100"`
	Domain      string    `db:"domain" json:"domain" validate:"nonzero,max=100"`
	DisplayName string    `db:"display_name" json:"display_name" validate:"max=100"`
	Created     time.Time `db:"created" json:"created_dt"`
}

DropID represents a golbally unique identification a user can ue to communicate with other DropServer instances

type ErrorCode

type ErrorCode int

ErrorCode represents integer codes for each error mesage

type JobID

type JobID int

JobID is the id of appspace migration job

type LogChunk

type LogChunk struct {
	From    int64  `json:"from"`
	To      int64  `json:"to"`
	Content string `json:"content"`
}

AppspaceLogChunk contains a part of an appspace Log as a string and the from and to bytes that this string represents in the log

type LogLevel

type LogLevel int

LogLevel represents the logging severity level

const (
	DEBUG LogLevel = iota
	INFO  LogLevel = iota
	WARN  LogLevel = iota
	ERROR LogLevel = iota
	// DISABLE Maximum level, disables sending or printing
	DISABLE LogLevel = iota
)

DEBUG is for debug

type LoggerI

type LoggerI interface {
	Log(source, message string)
	SubscribeStatus() (bool, <-chan bool)
	UnsubscribeStatus(ch <-chan bool)
	GetLastBytes(n int64) (LogChunk, error)
	SubscribeEntries(n int64) (LogChunk, <-chan string, error)
	UnsubscribeEntries(ch <-chan string)
}

LoggerI is interface for appspace and app log

type LoginViewData

type LoginViewData struct {
	Message string
	Email   string
}

LoginViewData is used to pass messages and parameters to the login page

type MetricsI

type MetricsI interface {
	HostHandleReq(start time.Time)
}

MetricsI represents the global Metrics interface

type MigrationJob

type MigrationJob struct {
	JobID      JobID                `db:"job_id" json:"job_id"`
	OwnerID    UserID               `db:"owner_id" json:"owner_id"`
	AppspaceID AppspaceID           `db:"appspace_id" json:"appspace_id"`
	ToVersion  Version              `db:"to_version" json:"to_version"`
	Created    time.Time            `db:"created" json:"created"`
	Started    nulltypes.NullTime   `db:"started" json:"started"`
	Finished   nulltypes.NullTime   `db:"finished" json:"finished"`
	Priority   bool                 `db:"priority" json:"priority"`
	Error      nulltypes.NullString `db:"error" json:"error"`
}

MigrationJob describes a pending or ongoing appspace migration job

type MigrationJobStatus

type MigrationJobStatus int

MigrationJobStatus represents the Status of an appspace's migration to a different version including possibly a different schema

const (
	// MigrationStarted means the job has started
	MigrationStarted MigrationJobStatus = iota + 1
	// MigrationRunning means the migration sandbox is running and migrating schemas
	MigrationRunning
	// MigrationFinished means the migration is complete or ended with an error
	MigrationFinished
)

type MigrationStep

type MigrationStep struct {
	Direction string `json:"direction"`
	Schema    int    `json:"schema"`
}

migration data comign from sandbox: this should also include description as string. Maybe an explicit "lossy" flag? Or Lossless so taht default false doesn't imply things that aren't true.

type MockAppspaceRouteModels

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

MockAppspaceRouteModels is a mock of AppspaceRouteModels interface

func NewMockAppspaceRouteModels

func NewMockAppspaceRouteModels(ctrl *gomock.Controller) *MockAppspaceRouteModels

NewMockAppspaceRouteModels creates a new mock instance

func (*MockAppspaceRouteModels) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockAppspaceRouteModels) GetV0

GetV0 mocks base method

type MockAppspaceRouteModelsMockRecorder

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

MockAppspaceRouteModelsMockRecorder is the mock recorder for MockAppspaceRouteModels

func (*MockAppspaceRouteModelsMockRecorder) GetV0

func (mr *MockAppspaceRouteModelsMockRecorder) GetV0(arg0 interface{}) *gomock.Call

GetV0 indicates an expected call of GetV0

type MockMetricsI

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

MockMetricsI is a mock of MetricsI interface

func NewMockMetricsI

func NewMockMetricsI(ctrl *gomock.Controller) *MockMetricsI

NewMockMetricsI creates a new mock instance

func (*MockMetricsI) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockMetricsI) HostHandleReq

func (m *MockMetricsI) HostHandleReq(arg0 time.Time)

HostHandleReq mocks base method

type MockMetricsIMockRecorder

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

MockMetricsIMockRecorder is the mock recorder for MockMetricsI

func (*MockMetricsIMockRecorder) HostHandleReq

func (mr *MockMetricsIMockRecorder) HostHandleReq(arg0 interface{}) *gomock.Call

HostHandleReq indicates an expected call of HostHandleReq

type MockSandboxI

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

MockSandboxI is a mock of SandboxI interface

func NewMockSandboxI

func NewMockSandboxI(ctrl *gomock.Controller) *MockSandboxI

NewMockSandboxI creates a new mock instance

func (*MockSandboxI) AppVersion

func (m *MockSandboxI) AppVersion() *AppVersion

AppVersion mocks base method

func (*MockSandboxI) AppspaceID

func (m *MockSandboxI) AppspaceID() NullAppspaceID

AppspaceID mocks base method

func (*MockSandboxI) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockSandboxI) ExecFn

func (m *MockSandboxI) ExecFn(arg0 AppspaceRouteHandler) error

ExecFn mocks base method

func (*MockSandboxI) GetTransport

func (m *MockSandboxI) GetTransport() http.RoundTripper

GetTransport mocks base method

func (*MockSandboxI) Graceful

func (m *MockSandboxI) Graceful()

Graceful mocks base method

func (*MockSandboxI) Kill

func (m *MockSandboxI) Kill()

Kill mocks base method

func (*MockSandboxI) LastActive

func (m *MockSandboxI) LastActive() time.Time

LastActive mocks base method

func (*MockSandboxI) NewTask

func (m *MockSandboxI) NewTask() chan struct{}

NewTask mocks base method

func (*MockSandboxI) Operation

func (m *MockSandboxI) Operation() string

Operation mocks base method

func (*MockSandboxI) OwnerID

func (m *MockSandboxI) OwnerID() UserID

OwnerID mocks base method

func (*MockSandboxI) SendMessage

func (m *MockSandboxI) SendMessage(arg0, arg1 int, arg2 []byte) (twine.SentMessageI, error)

SendMessage mocks base method

func (*MockSandboxI) Start

func (m *MockSandboxI) Start()

Start mocks base method

func (*MockSandboxI) Status

func (m *MockSandboxI) Status() SandboxStatus

Status mocks base method

func (*MockSandboxI) TiedUp

func (m *MockSandboxI) TiedUp() bool

TiedUp mocks base method

func (*MockSandboxI) WaitFor

func (m *MockSandboxI) WaitFor(arg0 SandboxStatus)

WaitFor mocks base method

type MockSandboxIMockRecorder

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

MockSandboxIMockRecorder is the mock recorder for MockSandboxI

func (*MockSandboxIMockRecorder) AppVersion

func (mr *MockSandboxIMockRecorder) AppVersion() *gomock.Call

AppVersion indicates an expected call of AppVersion

func (*MockSandboxIMockRecorder) AppspaceID

func (mr *MockSandboxIMockRecorder) AppspaceID() *gomock.Call

AppspaceID indicates an expected call of AppspaceID

func (*MockSandboxIMockRecorder) ExecFn

func (mr *MockSandboxIMockRecorder) ExecFn(arg0 interface{}) *gomock.Call

ExecFn indicates an expected call of ExecFn

func (*MockSandboxIMockRecorder) GetTransport

func (mr *MockSandboxIMockRecorder) GetTransport() *gomock.Call

GetTransport indicates an expected call of GetTransport

func (*MockSandboxIMockRecorder) Graceful

func (mr *MockSandboxIMockRecorder) Graceful() *gomock.Call

Graceful indicates an expected call of Graceful

func (*MockSandboxIMockRecorder) Kill

func (mr *MockSandboxIMockRecorder) Kill() *gomock.Call

Kill indicates an expected call of Kill

func (*MockSandboxIMockRecorder) LastActive

func (mr *MockSandboxIMockRecorder) LastActive() *gomock.Call

LastActive indicates an expected call of LastActive

func (*MockSandboxIMockRecorder) NewTask

func (mr *MockSandboxIMockRecorder) NewTask() *gomock.Call

NewTask indicates an expected call of NewTask

func (*MockSandboxIMockRecorder) Operation

func (mr *MockSandboxIMockRecorder) Operation() *gomock.Call

Operation indicates an expected call of Operation

func (*MockSandboxIMockRecorder) OwnerID

func (mr *MockSandboxIMockRecorder) OwnerID() *gomock.Call

OwnerID indicates an expected call of OwnerID

func (*MockSandboxIMockRecorder) SendMessage

func (mr *MockSandboxIMockRecorder) SendMessage(arg0, arg1, arg2 interface{}) *gomock.Call

SendMessage indicates an expected call of SendMessage

func (*MockSandboxIMockRecorder) Start

func (mr *MockSandboxIMockRecorder) Start() *gomock.Call

Start indicates an expected call of Start

func (*MockSandboxIMockRecorder) Status

func (mr *MockSandboxIMockRecorder) Status() *gomock.Call

Status indicates an expected call of Status

func (*MockSandboxIMockRecorder) TiedUp

func (mr *MockSandboxIMockRecorder) TiedUp() *gomock.Call

TiedUp indicates an expected call of TiedUp

func (*MockSandboxIMockRecorder) WaitFor

func (mr *MockSandboxIMockRecorder) WaitFor(arg0 interface{}) *gomock.Call

WaitFor indicates an expected call of WaitFor

type MockStdInput

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

MockStdInput is a mock of StdInput interface

func NewMockStdInput

func NewMockStdInput(ctrl *gomock.Controller) *MockStdInput

NewMockStdInput creates a new mock instance

func (*MockStdInput) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockStdInput) ReadLine

func (m *MockStdInput) ReadLine(arg0 string) string

ReadLine mocks base method

type MockStdInputMockRecorder

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

MockStdInputMockRecorder is the mock recorder for MockStdInput

func (*MockStdInputMockRecorder) ReadLine

func (mr *MockStdInputMockRecorder) ReadLine(arg0 interface{}) *gomock.Call

ReadLine indicates an expected call of ReadLine

type MockV0RouteModel

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

MockV0RouteModel is a mock of V0RouteModel interface

func NewMockV0RouteModel

func NewMockV0RouteModel(ctrl *gomock.Controller) *MockV0RouteModel

NewMockV0RouteModel creates a new mock instance

func (*MockV0RouteModel) Create

func (m *MockV0RouteModel) Create(arg0 []string, arg1 string, arg2 AppspaceRouteAuth, arg3 AppspaceRouteHandler) error

Create mocks base method

func (*MockV0RouteModel) Delete

func (m *MockV0RouteModel) Delete(arg0 []string, arg1 string) error

Delete mocks base method

func (*MockV0RouteModel) EXPECT

EXPECT returns an object that allows the caller to indicate expected use

func (*MockV0RouteModel) Get

func (m *MockV0RouteModel) Get(arg0 []string, arg1 string) (*[]AppspaceRouteConfig, error)

Get mocks base method

func (*MockV0RouteModel) GetAll

func (m *MockV0RouteModel) GetAll() (*[]AppspaceRouteConfig, error)

GetAll mocks base method

func (*MockV0RouteModel) GetPath

func (m *MockV0RouteModel) GetPath(arg0 string) (*[]AppspaceRouteConfig, error)

GetPath mocks base method

func (*MockV0RouteModel) HandleMessage

func (m *MockV0RouteModel) HandleMessage(arg0 twine.ReceivedMessageI)

HandleMessage mocks base method

func (*MockV0RouteModel) Match

func (m *MockV0RouteModel) Match(arg0, arg1 string) (*AppspaceRouteConfig, error)

Match mocks base method

type MockV0RouteModelMockRecorder

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

MockV0RouteModelMockRecorder is the mock recorder for MockV0RouteModel

func (*MockV0RouteModelMockRecorder) Create

func (mr *MockV0RouteModelMockRecorder) Create(arg0, arg1, arg2, arg3 interface{}) *gomock.Call

Create indicates an expected call of Create

func (*MockV0RouteModelMockRecorder) Delete

func (mr *MockV0RouteModelMockRecorder) Delete(arg0, arg1 interface{}) *gomock.Call

Delete indicates an expected call of Delete

func (*MockV0RouteModelMockRecorder) Get

func (mr *MockV0RouteModelMockRecorder) Get(arg0, arg1 interface{}) *gomock.Call

Get indicates an expected call of Get

func (*MockV0RouteModelMockRecorder) GetAll

GetAll indicates an expected call of GetAll

func (*MockV0RouteModelMockRecorder) GetPath

func (mr *MockV0RouteModelMockRecorder) GetPath(arg0 interface{}) *gomock.Call

GetPath indicates an expected call of GetPath

func (*MockV0RouteModelMockRecorder) HandleMessage

func (mr *MockV0RouteModelMockRecorder) HandleMessage(arg0 interface{}) *gomock.Call

HandleMessage indicates an expected call of HandleMessage

func (*MockV0RouteModelMockRecorder) Match

func (mr *MockV0RouteModelMockRecorder) Match(arg0, arg1 interface{}) *gomock.Call

Match indicates an expected call of Match

type NullAppspaceID

type NullAppspaceID struct {
	sql.NullInt32
}

NullString is an alias for mysql.NullTime data type

func NewNullAppspaceID

func NewNullAppspaceID(a ...AppspaceID) (ret NullAppspaceID)

NewString creates a new Time.

func (NullAppspaceID) Equal

func (n NullAppspaceID) Equal(c NullAppspaceID) bool

func (*NullAppspaceID) Get

func (n *NullAppspaceID) Get() (AppspaceID, bool)

func (*NullAppspaceID) MarshalJSON

func (n *NullAppspaceID) MarshalJSON() ([]byte, error)

MarshalJSON for NullAppspaceID

func (*NullAppspaceID) Set

func (n *NullAppspaceID) Set(a AppspaceID)

SetString sets valid to tru and sets string field

func (*NullAppspaceID) Unset

func (n *NullAppspaceID) Unset()

SetNull sets the Valied filed to fals and zeros the string

type ProxyID

type ProxyID string

ProxyID is an appspace user's id as seen from the appspace

func CtxAppspaceUserProxyID

func CtxAppspaceUserProxyID(ctx context.Context) (ProxyID, bool)

CtxAppspaceUserProxyID gets the appspace data that is solely relevant to the request

type RemoteAppspace

type RemoteAppspace struct {
	UserID      UserID    `db:"user_id"`
	DomainName  string    `db:"domain_name"`
	OwnerDropID string    `db:"owner_dropid"`
	UserDropID  string    `db:"dropid"`
	Created     time.Time `db:"created"`
}

type ReverseServiceI

type ReverseServiceI interface {
	HandleMessage(twine.ReceivedMessageI)
}

ReverseServiceI is a common interface for reverse services of all versions

type RuntimeConfig

type RuntimeConfig struct {
	DataDir string `json:"data-dir"`
	Server  struct {
		Port    int16  `json:"port"`
		Host    string `json:"host"`
		SslCert string `json:"ssl-cert"`
		SslKey  string `json:"ssl-key"`
	} `json:"server"`
	// NoTLS indicates that this instance should be accessed from the outside without TLS
	NoTLS bool `json:"no-tls"`
	// PortString sets the port that will be appended to domains pointing to your instance.
	// If your instance is exposed to the outside world on a non-standard port,
	// use this setting to ensure generated links are correct.
	// Example: ":5050"
	PortString string `json:"port-string"`
	TrustCert  string `json:"trust-cert"`
	Subdomains struct {
		UserAccounts string `json:"user-accounts"`
		StaticAssets string `json:"static-assets"` // this can't just be a subdomain, has to be full domain, (but you could use a cname in DNS, right)
	} `json:"subdomains"`
	Sandbox struct {
		SocketsDir  string `json:"sockets-dir"` // do we really need this? could we not put it in DataDir/sockets?
		Num         int    `json:"num"`
		UseCGroups  bool   `json:"use-cgroups"`
		CGroupMount string `json:"cgroup-mount"`
		// MemoryBytesMb is the memory.high value for the cgroup that is parent of all sandboxe cgroups
		MemoryHighMb int `json:"memory-high-mb"`
	} `json:"sandbox"`
	Log        string `json:"log"`
	Prometheus struct {
		Enable bool   `json:"enable"`
		Port   uint16 `json:"port"`
	} `json:"prometheus"`
	// Exec contains values determined at runtime
	// These are not settable via json.
	Exec struct {
		UserRoutesDomain string
		SandboxCodePath  string
		AppsPath         string
		AppspacesPath    string
	}
}

RuntimeConfig represents the variables that can be set at runtime Or at least set via config file or cli flags that get read once upon starting ds-host. This is for server-side use only.

type SandboxI

type SandboxI interface {
	OwnerID() UserID
	Operation() string
	AppspaceID() NullAppspaceID
	AppVersion() *AppVersion
	ExecFn(AppspaceRouteHandler) error
	SendMessage(int, int, []byte) (twine.SentMessageI, error)
	GetTransport() http.RoundTripper
	TiedUp() bool
	LastActive() time.Time
	NewTask() chan struct{}
	Status() SandboxStatus
	WaitFor(SandboxStatus)
	Start()
	Graceful()
	Kill()
}

SandboxI describes the interface to a sandbox

type SandboxRun

type SandboxRun struct {
	SandboxRunIDs
	SandboxRunData
	Start time.Time          `db:"start" json:"start"`
	End   nulltypes.NullTime `db:"end" json:"end"`
}

type SandboxRunData

type SandboxRunData struct {
	TiedUpMs      int `db:"tied_up_ms" json:"tied_up_ms"`
	CpuUsec       int `db:"cpu_usec" json:"cpu_usec"`
	MemoryByteSec int `db:"memory_byte_sec" json:"memory_byte_sec"`
	IOBytes       int `db:"io_bytes" json:"io_bytes"`
	IOs           int `db:"io_ops" json:"io_ops"`
}

SandboxRunData contains the metrics of a sandbox run

type SandboxRunIDs

type SandboxRunIDs struct {
	SandboxID  int            `db:"sandbox_id" json:"sandbox_id"`
	Instance   string         `db:"instance" json:"instance"`
	LocalID    int            `db:"local_id" json:"local_id"`
	OwnerID    UserID         `db:"owner_id" json:"owner_id"`
	AppID      AppID          `db:"app_id" json:"app_id"`
	Version    Version        `db:"version" json:"version"`
	AppspaceID NullAppspaceID `db:"appspace_id" json:"appspace_id"`
	Operation  string         `db:"operation" json:"operation"`
	CGroup     string         `db:"cgroup" json:"cgroup"`
}

SandboxRunIDs contains all the identifiers relevant to a sandbox run

type SandboxStatus

type SandboxStatus int

SandboxStatus represents the Status of a Sandbox

const (
	// SandboxPrepared is the initial status
	SandboxPrepared SandboxStatus = iota + 1
	// SandboxStarting sb is starting not ready yet
	SandboxStarting
	// SandboxReady means it's ready to take incoming requests
	SandboxReady
	// SandboxKilling means the system considers it is going down
	SandboxKilling
	// SandboxDead means the PID is dead
	SandboxDead
	// SandboxCleanedUp means metrics have been collected and traces of sandbox removed.
	SandboxCleanedUp
)

type Settings

type Settings struct {
	RegistrationOpen bool `json:"registration_open" db:"registration_open"` //may not need json here?
}

Settings represents admin-settable parameters

type SignupViewData

type SignupViewData struct {
	RegistrationOpen bool
	// username?
	Message string
	Email   string
}

SignupViewData is used to pass messages and parameters to the login page

type StdInput

type StdInput interface {
	ReadLine(string) string
}

StdInput gives ability to read from the command line

type TimedToken

type TimedToken struct {
	Token   string
	Created time.Time
}

type TwineService

type TwineService interface {
	Start(UserID, *twine.Twine)
	HandleMessage(twine.ReceivedMessageI)
}

TwineService attach to a twine instance to handle two-way communication with a remote twine client

type TwineService2

type TwineService2 interface {
	Start(UserID, *twine.Twine) TwineServiceI
}

TwineService2 returns a TwineServiceI on start

type TwineServiceI

type TwineServiceI interface {
	HandleMessage(twine.ReceivedMessageI)
}

TwineServiceI handles incoming messages for a twine connection

type User

type User struct {
	UserID UserID `db:"user_id"`
	Email  string
}

User is basic representation of a DropServer User

type UserID

type UserID uint32

UserID represents the user ID

func CtxAuthUserID

func CtxAuthUserID(ctx context.Context) (UserID, bool)

CtxAuthUserID gets the authenticated user id from the context Second value is false if no auth user id

type UserInvitation

type UserInvitation struct {
	Email string `db:"email" json:"email"`
}

UserInvitation represents an invitation for a user to join the DropServer instance

type V0AppRoute

type V0AppRoute struct {
	ID      string            `json:"id"`
	Method  string            `json:"method"`
	Path    V0AppRoutePath    `json:"path"` // Path is the request path to match
	Auth    AppspaceRouteAuth `json:"auth"`
	Type    string            `json:"type"`    // Type of handler: "function" or "static" for now
	Options V0AppRouteOptions `json:"options"` // Options for the route handler
}

V0AppRoute is route config for appspace as stored with app

func CtxV0RouteConfig

func CtxV0RouteConfig(ctx context.Context) (V0AppRoute, bool)

CtxRouteConfig gets the appspace route config data for the request

type V0AppRouteOptions

type V0AppRouteOptions struct {
	Name string `json:"name,omitempty"` // this is called "location" downstream. (but why?)
	Path string `json:"path,omitempty"`
}

V0AppRouteOptions is a JSON friendly struct that describes the desired handling for the route

type V0AppRoutePath

type V0AppRoutePath struct {
	Path string `json:"path"`
	End  bool   `json:"end"` // End of false makes the path a wildcard /path/**
}

V0AppRoutePath is the request path twe are seeking to match

type V0AppspaceDBQuery

type V0AppspaceDBQuery struct {
	DBName      string                 `json:"db_name"`
	Type        string                 `json:"type"` // "query" or "exec"
	SQL         string                 `json:"sql"`
	Params      []interface{}          `json:"params"`
	NamedParams map[string]interface{} `json:"named_params"`
}

V0AppspaceDBQuery is the structure expected when Posting a DB request

type V0AppspaceLoginToken

type V0AppspaceLoginToken struct {
	AppspaceID AppspaceID
	DropID     string
	ProxyID    ProxyID
	LoginToken TimedToken
}

V0AppspaceLoginToken carries user auth data corresponding to a login token

type V0LoginTokenRequest

type V0LoginTokenRequest struct {
	DropID string `json:"dropid"`
	Ref    string `json:"ref"`
}

V0LoginTokenRequest is sent to the host that manages the appspace

type V0LoginTokenResponse

type V0LoginTokenResponse struct {
	Appspace string `json:"appspace"`
	Token    string `json:"token"`
	Ref      string `json:"ref"`
}

V0PostLoginToken is the data sent from appspace host to dropid host when a user requests a token to remote log-in

type V0RouteModel

type V0RouteModel interface {
	ReverseServiceI

	Create(methods []string, url string, auth AppspaceRouteAuth, handler AppspaceRouteHandler) error

	// Get returns all routes that
	// - match one of the methods passed, and
	// - matches the routePath exactly (no interpolation is done to match sub-paths)
	Get(methods []string, routePath string) (*[]AppspaceRouteConfig, error)
	GetAll() (*[]AppspaceRouteConfig, error)
	GetPath(string) (*[]AppspaceRouteConfig, error)

	Delete(methods []string, url string) error

	// Match finds the route that should handle the request
	// The path will be broken into parts to find the subset path that matches.
	// It returns (nil, nil) if no matches found
	Match(method string, url string) (*AppspaceRouteConfig, error)
}

V0RouteModel serves route data queries at version 0

type Version

type Version string

Version is a version string like 0.0.1

Jump to

Keyboard shortcuts

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