Documentation
¶
Index ¶
- func ExecValueFunctionOnPluginGoRoutine[R any](container IPMAASContainer, f func() R, defaultValueFn func() R, ...) (R, error)
- type CompiledTemplate
- type EntityInvocationHandlerFunc
- type EntityRenderFunc
- type EntityRenderer
- type EntityRendererFactory
- type EntityStubFactoryFunc
- type IPMAASContainer
- type IPMAASPlugin
- type IPMAASRenderPlugin
- type IPMAASTemplateEnginePlugin
- type ITemplate
- type RenderListOptions
- type StreamingEntityRenderFunc
- type TemplateInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExecValueFunctionOnPluginGoRoutine ¶
func ExecValueFunctionOnPluginGoRoutine[R any]( container IPMAASContainer, f func() R, defaultValueFn func() R, errorMessage string) (R, error)
Types ¶
type CompiledTemplate ¶
type EntityRenderFunc ¶
type EntityRenderer ¶
type EntityRenderer struct {
RenderFunc EntityRenderFunc
StreamingRenderFunc StreamingEntityRenderFunc
Styles []string
Scripts []string
}
func TemplateBasedRendererFactory ¶
func TemplateBasedRendererFactory( container IPMAASContainer, templateInfo *TemplateInfo, typeCheckFn func(any) bool, typeName string) (EntityRenderer, error)
type EntityRendererFactory ¶
type EntityRendererFactory func() (EntityRenderer, error)
type EntityStubFactoryFunc ¶
type IPMAASContainer ¶
type IPMAASContainer interface {
AddRoute(path string, handlerFunc http.HandlerFunc)
BroadcastEvent(entityEventId string, event any) error
RenderList(w http.ResponseWriter, r *http.Request, options RenderListOptions, items []interface{})
GetTemplate(templateInfo *TemplateInfo) (CompiledTemplate, error)
GetEntityRenderer(entityType reflect.Type) (EntityRenderer, error)
RegisterEntityRenderer(entityType reflect.Type, renderFactory EntityRendererFactory)
EnableStaticContent(staticContentDir string)
// ProvideContentFS Registers an io/fs.FS instance that the server can use to read plugin resources such as
// templates or static file content for serving over HTTP.
ProvideContentFS(fs fs.FS, prefix string)
// RegisterEntity Registers an entity with server. This gives it a unique name, which can later be looked up for
// further interaction with the entity.
RegisterEntity(
uniqueData string,
entityType reflect.Type,
name string,
stubFactoryFn EntityStubFactoryFunc) (string, error)
// DeregisterEntity Removes an entity previously registered with the server. Pass the ID returned from the
// previous call to RegisterEntity.
DeregisterEntity(id string) error
// AssertEntityType Verifies that an entity with the given ID exists and is of the passed type
AssertEntityType(pmaasEntityId string, entityType reflect.Type) error
// GetEntities Returns a list of entities that match the supplied predicate.
GetEntities(predicate func(info *entity.RegisteredEntityInfo) bool) ([]entity.RegisteredEntityInfo, error)
// InvokeOnEntity Invokes the supplied function on the plugin-runner goroutine of the plugin that owns the specified
//entity, supplying the entity.
InvokeOnEntity(id string, function func(entity any)) error
// RegisterEventReceiver Registers a receiver for events. If successful, returns an integer handle that can be used
// to deregister the handler in the future.
RegisterEventReceiver(predicate events.EventPredicate, receiver events.EventReceiver) (int, error)
// DeregisterEventReceiver Removes a previously registered event receiver
DeregisterEventReceiver(receiverHandle int) error
// EnqueueOnPluginGoRoutine Enqueues the passed function for execution on the plugin's main GoRoutine.
// Returns an error if the function cannot be enqueued. This method returns as soon as the function
// is enqueued, it does not wait for execution. If you need the results of the execution, you'll need to
// orchestrate that in the function. For example, the function can send the result back via a channel.
// Warning: Calling this function when already executing on the plugin's main GoRoutine will result in deadlock.
EnqueueOnPluginGoRoutine(f func()) error
// EnqueueOnServerGoRoutine Enqueues the passed functions for execution on the server's main GoRoutine.
// The server's main GoRoutine is the one used to call PMAAS.Run().
// Use this to execute callbacks registered during the server configuration phase.
EnqueueOnServerGoRoutine(invocations []func()) error
// ClosedCallbackChannel returns an already closed callback channel. You can use this when you know
// there will not be a need for any callbacks.
ClosedCallbackChannel() chan func()
}
IPMAASContainer is an interface for plugins to interact with the PMAAS server.
type IPMAASPlugin ¶
type IPMAASPlugin interface {
Init(container IPMAASContainer)
Start()
Stop() chan func()
}
IPMAASPlugin is the interface all plugins must implement. The core will call Init, Start, and Stop in sequence, all from the same go routine.
All of these functions will be called on the plugin's main goroutine.
The Stop function must not block. If there is blocking work to be done, do the work in a new or separate goroutine, and inform the server that it's complete by closing the returned channel. The Stop function can also request additional callbacks by sending functions to the returned channel.
type IPMAASRenderPlugin ¶
type IPMAASRenderPlugin interface {
IPMAASPlugin
RenderList(w http.ResponseWriter, r *http.Request, options RenderListOptions, items []interface{})
}
type IPMAASTemplateEnginePlugin ¶
type IPMAASTemplateEnginePlugin interface {
IPMAASPlugin
GetTemplate(templateInfo *TemplateInfo) (CompiledTemplate, error)
}
type RenderListOptions ¶
Source Files
¶
Click to show internal directories.
Click to hide internal directories.