modules

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

README

DGate Module Specification

Module Types

Request

Request

  • functions
    • body()
      • returns the request body
  • properties
    • status
// this keyword has the same type for each module/function, which is the ModuleContext, this contains a snapshot of any metadata information that is available to the module.
interface ModuleContext {
    // this is the request object (requires request permission/minimal)
    request: Request;
    // this is the response object, this may not available for all modules (requires response permission/minimal)
    response: Response;

    // this is the namespace object (requires namespace permission/basic)
    namespace: Namespace;
    // this is the service object (requires service permission/basic)
    service: Service;
    // this is the route object (requires route permission/basic)
    route: Route;
    // this is the module object (requires module permission/basic)
    module: Module;
    
    // this is the node object (requires node permission/advanced)
    node: Node;
    // this is the cluster object (requires cluster permission/advanced)
    cluster: Cluster;
}

function exampleModule(): string {
    const tags = this.node.tags;
    const version = this.node.version;
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exports

type Exports struct {
	// Default is what will be the `default` export of a module
	Default any
	// Named is the named exports of a module
	Named map[string]any
}

type GoModule

type GoModule interface {
	Exports() *Exports
}

type Module

type Module interface {
	New(RuntimeContext) GoModule
}

type RuntimeContext

type RuntimeContext interface {
	Context() context.Context
	EventLoop() *eventloop.EventLoop
	Runtime() *goja.Runtime
	State() StateManager
}

type StateManager

type StateManager interface {
	ApplyChangeLog(*spec.ChangeLog) error
	ResourceManager() *resources.ResourceManager
	DocumentManager() resources.DocumentManager
	Scheduler() scheduler.Scheduler
	SharedCache() cache.TCache
}

Directories

Path Synopsis
exp

Jump to

Keyboard shortcuts

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