apprunner

package
v0.0.0-...-e9c30ff Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 58 Imported by: 0

Documentation

Index

Constants

View Source
const MainFileName = "main.js"

MainFileName is the name of the application file containing the application entry point

View Source
const MainFileNameTypeScript = "main.ts"

MainFileNameTypeScript is the name of the application TypeScript file containing the application entry point

View Source
const RuntimeVersion = 1

RuntimeVersion is the version of the application runtime

View Source
const ServerScriptMIMEType = javaScriptMIMEType

ServerScriptMIMEType is the content type of the application scripts executed by the server

View Source
const TypeScriptVersion = "v4.9.3"

TypeScriptVersion currently used by the application runtime

Variables

View Source
var ErrApplicationFileNotFound = errors.New("application file not found")
View Source
var ErrApplicationFileTypeMismatch = errors.New("unexpected type for application file")
View Source
var ErrApplicationInstanceAlreadyPaused = errors.New("application instance already paused")
View Source
var ErrApplicationInstanceAlreadyRunning = errors.New("application instance already running")
View Source
var ErrApplicationInstanceNotRunning = errors.New("application instance not running")

ErrApplicationInstanceNotRunning is returned when the specified application is not running

View Source
var ErrApplicationInstanceTerminated = errors.New("application instance terminated")
View Source
var ErrApplicationLogNotFound = errors.New("application log not found")

ErrApplicationLogNotFound is returned when the log for the specified application, or the specified application, was not found

View Source
var ErrApplicationNotEnabled = errors.New("application not enabled")

ErrApplicationNotEnabled is returned when the specified application is not allowed to launch

View Source
var ErrApplicationNotFound = errors.New("application not found")

ErrApplicationNotFound is returned when the specified application was not found

View Source
var ErrApplicationNotInstantiated = errors.New("application not instantiated")

ErrApplicationNotInstantiated is returned when the specified application is not instantiated

Functions

func NewAppLogger

func NewAppLogger(applicationID string) *appLogger

Types

type AppRunner

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

AppRunner launches applications and manages their lifecycle

func New

func New(
	workerContext context.Context,
	log *log.Logger,
	configManager *configurationmanager.Manager,
	notifManager *notificationmanager.Manager,
	walletBuilder WalletBuilder) *AppRunner

New returns a new initialized AppRunner

func (*AppRunner) ApplicationEvent

func (r *AppRunner) ApplicationEvent(ctx context.Context, trusted bool, applicationID, pageID string, eventName string, eventArgs []string) error

func (*AppRunner) ApplicationLaunched

func (r *AppRunner) ApplicationLaunched() event.Event[RunningApplication]

ApplicationLaunched is the event that is fired when an application is launched

func (*AppRunner) ApplicationLog

func (r *AppRunner) ApplicationLog(applicationID string) (ApplicationLog, error)

ApplicationLog returns the log for a running or recently stopped application

func (*AppRunner) ApplicationMethod

func (r *AppRunner) ApplicationMethod(ctx context.Context, applicationID, pageID, method string, args []string) (string, error)

func (*AppRunner) ApplicationStopped

func (r *AppRunner) ApplicationStopped() event.Event[RunningApplication]

ApplicationStopped is the event that is fired when an application is stopped

func (*AppRunner) BuildApplicationWallet

func (r *AppRunner) BuildApplicationWallet(ctxCtx context.Context, applicationID string) (*wallet.Wallet, error)

func (*AppRunner) ConsumeApplicationEvents

func (r *AppRunner) ConsumeApplicationEvents(ctx context.Context, applicationID, pageID string) (<-chan rpc.ClientEventData, func(), error)

func (*AppRunner) EvaluateExpressionOnApplication

func (r *AppRunner) EvaluateExpressionOnApplication(ctx context.Context, applicationID, expression string) (bool, string, time.Duration, error)

func (*AppRunner) IsRunning

func (r *AppRunner) IsRunning(applicationID string) (bool, types.ApplicationVersion, time.Time)

IsRunning returns whether the application with the given ID is running and if yes, also its running version and start time

func (*AppRunner) LaunchApplication

func (r *AppRunner) LaunchApplication(applicationID string) error

LaunchApplication launches the most recent version of the specified application

func (*AppRunner) LaunchApplicationAtVersion

func (r *AppRunner) LaunchApplicationAtVersion(applicationID string, applicationVersion types.ApplicationVersion) error

LaunchApplication launches the most recent version of the specified application

func (*AppRunner) LaunchAutorunApplications

func (r *AppRunner) LaunchAutorunApplications() error

LaunchAutorunApplications launches all the applications set to run on startup

func (*AppRunner) ResolvePage

func (r *AppRunner) ResolvePage(applicationID, pageID string) (pages.PageInfo, types.ApplicationVersion, bool)

func (*AppRunner) RunningApplications

func (r *AppRunner) RunningApplications() []RunningApplication

RunningApplications returns a list of running applications

func (*AppRunner) RunningApplicationsUpdated

func (r *AppRunner) RunningApplicationsUpdated() event.Event[[]RunningApplication]

RunningApplicationsUpdated is the event that is fired when the list of running applications changes

func (*AppRunner) ServeFile

func (r *AppRunner) ServeFile(ctx context.Context, applicationID, fileName string, w http.ResponseWriter, req *http.Request) error

func (*AppRunner) SetModuleDependencies

func (r *AppRunner) SetModuleDependencies(d modules.Dependencies)

func (*AppRunner) StopApplication

func (r *AppRunner) StopApplication(applicationID string) error

StopApplication stops the specified application

type ApplicationLog

type ApplicationLog interface {
	// LogEntries returns log entries older than offset, sorted from newest to oldest
	LogEntries(offset ulid.ULID, maxCount int, levels []ApplicationLogLevel) ([]ApplicationLogEntry, bool)

	// LogEntriesSince returns log entries newer than offset, sorted from oldest to newest
	LogEntriesSince(offset ulid.ULID, levels []ApplicationLogLevel) []ApplicationLogEntry

	// LogEntryAdded is notified when a new log entry is added
	LogEntryAdded() event.Event[ApplicationLogEntry]
}

ApplicationLog represents the log of a single application

type ApplicationLogEntry

type ApplicationLogEntry interface {
	Cursor() ulid.ULID
	CreatedAt() time.Time
	Message() string
	LogLevel() ApplicationLogLevel
}

ApplicationLogEntry represents an entry in the log of an application

type ApplicationLogLevel

type ApplicationLogLevel int

ApplicationLogLevel represents the log level of an application log entry

const (
	ApplicationLogLevelJSLog ApplicationLogLevel = iota
	ApplicationLogLevelJSWarn
	ApplicationLogLevelJSError
	ApplicationLogLevelRuntimeLog
	ApplicationLogLevelRuntimeError
)

type RunningApplication

type RunningApplication struct {
	ApplicationID      string
	ApplicationVersion types.ApplicationVersion
	StartedAt          time.Time
}

RunningApplication contains information about a running application

type WalletBuilder

type WalletBuilder interface {
	BuildApplicationWallet(applicationID string, earliestVersion types.ApplicationVersion) (*wallet.Wallet, error)
}

WalletBuilder builds wallets for an application

Directories

Path Synopsis
db
rpc

Jump to

Keyboard shortcuts

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