Documentation ¶
Index ¶
- Constants
- Variables
- func NewAppLogger(applicationID string) *appLogger
- type AppRunner
- func (r *AppRunner) ApplicationEvent(ctx context.Context, trusted bool, applicationID, pageID string, ...) error
- func (r *AppRunner) ApplicationLaunched() event.Event[RunningApplication]
- func (r *AppRunner) ApplicationLog(applicationID string) (ApplicationLog, error)
- func (r *AppRunner) ApplicationMethod(ctx context.Context, applicationID, pageID, method string, args []string) (string, error)
- func (r *AppRunner) ApplicationStopped() event.Event[RunningApplication]
- func (r *AppRunner) BuildApplicationWallet(ctxCtx context.Context, applicationID string) (*wallet.Wallet, error)
- func (r *AppRunner) ConsumeApplicationEvents(ctx context.Context, stream grpc.ServerStream, applicationID, pageID string) (<-chan *grpc.PreparedMsg, func(), error)
- func (r *AppRunner) EvaluateExpressionOnApplication(ctx context.Context, applicationID, expression string) (bool, string, time.Duration, error)
- func (r *AppRunner) IsRunning(applicationID string) (bool, types.ApplicationVersion, time.Time)
- func (r *AppRunner) LaunchApplication(applicationID string) error
- func (r *AppRunner) LaunchApplicationAtVersion(applicationID string, applicationVersion types.ApplicationVersion) error
- func (r *AppRunner) LaunchAutorunApplications() error
- func (r *AppRunner) ResolvePage(applicationID, pageID string) (pages.PageInfo, types.ApplicationVersion, bool)
- func (r *AppRunner) RunningApplications() []RunningApplication
- func (r *AppRunner) RunningApplicationsUpdated() event.Event[[]RunningApplication]
- func (r *AppRunner) SendMessageToApplication(destinationApplicationID, sourceApplicationID, eventName string, ...) error
- func (r *AppRunner) ServeFile(ctx context.Context, applicationID, fileName string, w http.ResponseWriter, ...) error
- func (r *AppRunner) SetModuleDependencies(d modules.Dependencies)
- func (r *AppRunner) StopApplication(applicationID string) error
- type ApplicationLog
- type ApplicationLogEntry
- type ApplicationLogLevel
- type RunningApplication
- type WalletBuilder
Constants ¶
const MainFileName = "main.js"
MainFileName is the name of the application file containing the application entry point
const MainFileNameTypeScript = "main.ts"
MainFileNameTypeScript is the name of the application TypeScript file containing the application entry point
const RuntimeVersion = 1
RuntimeVersion is the version of the application runtime
const ServerScriptMIMEType = javaScriptMIMEType
ServerScriptMIMEType is the content type of the application scripts executed by the server
const TypeScriptVersion = "v4.9.3"
TypeScriptVersion currently used by the application runtime
Variables ¶
var ErrApplicationFileNotFound = errors.New("application file not found")
var ErrApplicationFileTypeMismatch = errors.New("unexpected type for application file")
var ErrApplicationInstanceAlreadyPaused = errors.New("application instance already paused")
var ErrApplicationInstanceAlreadyRunning = errors.New("application instance already running")
var ErrApplicationInstanceNotRunning = errors.New("application instance not running")
ErrApplicationInstanceNotRunning is returned when the specified application is not running
var ErrApplicationInstanceTerminated = errors.New("application instance terminated")
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
var ErrApplicationNotEnabled = errors.New("application not enabled")
ErrApplicationNotEnabled is returned when the specified application is not allowed to launch
var ErrApplicationNotFound = errors.New("application not found")
ErrApplicationNotFound is returned when the specified application was not found
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 (*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 (*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 (*AppRunner) ConsumeApplicationEvents ¶
func (r *AppRunner) ConsumeApplicationEvents(ctx context.Context, stream grpc.ServerStream, applicationID, pageID string) (<-chan *grpc.PreparedMsg, func(), error)
func (*AppRunner) EvaluateExpressionOnApplication ¶
func (*AppRunner) IsRunning ¶
IsRunning returns whether the application with the given ID is running and if yes, also its running version and start time
func (*AppRunner) LaunchApplication ¶
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 ¶
LaunchAutorunApplications launches all the applications set to run on startup
func (*AppRunner) ResolvePage ¶
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) SendMessageToApplication ¶
func (r *AppRunner) SendMessageToApplication(destinationApplicationID, sourceApplicationID, eventName string, serializedArgs []string) error
SendMessageToApplication is used by application instances to communicate between each other
func (*AppRunner) SetModuleDependencies ¶
func (r *AppRunner) SetModuleDependencies(d modules.Dependencies)
func (*AppRunner) StopApplication ¶
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 PublishedPages []pages.PageInfoAndID }
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