-
Notifications
You must be signed in to change notification settings - Fork 16
/
module.go
47 lines (39 loc) · 1.15 KB
/
module.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package modules
import (
"context"
"sync"
"time"
"github.com/dop251/goja"
"github.com/dop251/goja_nodejs/require"
"github.com/tnyim/jungletv/server/auth"
"github.com/tnyim/jungletv/types"
)
// NativeModule is a module that can be imported into a single application instance
type NativeModule interface {
ModuleLoader() require.ModuleLoader
ModuleName() string
IsNodeBuiltin() bool
AutoRequire() (bool, string)
ExecutionResumed(context.Context, *sync.WaitGroup, *goja.Runtime)
}
// ApplicationLogger logs application actions
type ApplicationLogger interface {
RuntimeAuditLog(s string)
}
// LifecycleManager can manage the application's execution lifecycle
type LifecycleManager interface {
AbortProcess()
ExitProcess(exitCode int)
}
// ApplicationContext is the context of an application as passed to a module instance
type ApplicationContext interface {
ApplicationID() string
ApplicationVersion() types.ApplicationVersion
ApplicationStartTime() time.Time
RuntimeVersion() int
ApplicationUser() auth.User
Logger() ApplicationLogger
LifecycleManager() LifecycleManager
Schedule(func(*goja.Runtime) error)
ScheduleNoError(func(*goja.Runtime))
}