plugins

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package plugins provides the gRPC server and client implementations for evoke plugins.

Index

Constants

This section is empty.

Variables

View Source
var Handshake = plugin.HandshakeConfig{
	ProtocolVersion:  1,
	MagicCookieKey:   "EVOKE_PLUGIN",
	MagicCookieValue: "1.0",
}

Handshake is a common handshake that is shared by plugin and host.

View Source
var PluginMap = map[string]plugin.Plugin{
	"evoke": &EvokePlugin{},
}

PluginMap is the map of plugins we can dispense.

Functions

This section is empty.

Types

type EvokeGRPCClient

type EvokeGRPCClient struct {
	Client proto.PluginClient
	// contains filtered or unexported fields
}

EvokeGRPCClient is an implementation of Plugin that talks over RPC.

func (*EvokeGRPCClient) Name added in v0.6.0

func (m *EvokeGRPCClient) Name() string

Name returns the name of the plugin.

func (*EvokeGRPCClient) OnConfigLoaded

func (m *EvokeGRPCClient) OnConfigLoaded(config []byte) ([]byte, error)

OnConfigLoaded is called after the configuration is loaded.

func (*EvokeGRPCClient) OnContentLoaded

func (m *EvokeGRPCClient) OnContentLoaded(path string, content []byte) ([]byte, error)

OnContentLoaded is called after a content file is loaded.

func (*EvokeGRPCClient) OnContentRender

func (m *EvokeGRPCClient) OnContentRender(path string, content []byte) ([]byte, error)

OnContentRender is called after a content file is rendered.

func (*EvokeGRPCClient) OnHTMLRendered

func (m *EvokeGRPCClient) OnHTMLRendered(path string, content []byte) ([]byte, error)

OnHTMLRendered is called after the HTML is rendered.

func (*EvokeGRPCClient) OnPostBuild

func (m *EvokeGRPCClient) OnPostBuild() error

OnPostBuild is called after the build process is finished.

func (*EvokeGRPCClient) OnPreBuild

func (m *EvokeGRPCClient) OnPreBuild() error

OnPreBuild is called before the build process starts.

func (*EvokeGRPCClient) OnPublicAssetsCopied

func (m *EvokeGRPCClient) OnPublicAssetsCopied() error

OnPublicAssetsCopied is called after the public assets are copied.

func (*EvokeGRPCClient) ProcessAsset

func (m *EvokeGRPCClient) ProcessAsset(asset *proto.Asset) (*proto.Asset, error)

ProcessAsset is called to process an asset with a custom pipeline.

func (*EvokeGRPCClient) RegisterPipelines

func (m *EvokeGRPCClient) RegisterPipelines() ([]*proto.Pipeline, error)

RegisterPipelines is called to register custom pipelines.

type EvokePlugin

type EvokePlugin struct {
	plugin.Plugin
	// Impl is the concrete implementation of the plugin.
	Impl Plugin
}

EvokePlugin is the implementation of plugin.Plugin so we can serve/consume plugins.

func (*EvokePlugin) GRPCClient

func (p *EvokePlugin) GRPCClient(ctx context.Context, broker *plugin.GRPCBroker, c *grpc.ClientConn) (interface{}, error)

GRPCClient returns the gRPC client for the plugin.

func (*EvokePlugin) GRPCServer

func (p *EvokePlugin) GRPCServer(broker *plugin.GRPCBroker, s *grpc.Server) error

GRPCServer registers the plugin with the gRPC server.

type GRPCServer

type GRPCServer struct {
	// Impl is the real implementation of the plugin.
	Impl Plugin
	proto.UnimplementedPluginServer
}

GRPCServer is the gRPC server that GRPCClient talks to.

func (*GRPCServer) OnConfigLoaded

OnConfigLoaded is called after the configuration is loaded.

func (*GRPCServer) OnContentLoaded

func (m *GRPCServer) OnContentLoaded(ctx context.Context, req *proto.ContentFile) (*proto.ContentFile, error)

OnContentLoaded is called after a content file is loaded.

func (*GRPCServer) OnContentRender

func (m *GRPCServer) OnContentRender(ctx context.Context, req *proto.ContentFile) (*proto.ContentFile, error)

OnContentRender is called after a content file is rendered.

func (*GRPCServer) OnHTMLRendered

func (m *GRPCServer) OnHTMLRendered(ctx context.Context, req *proto.ContentFile) (*proto.ContentFile, error)

OnHTMLRendered is called after the HTML is rendered.

func (*GRPCServer) OnPostBuild

OnPostBuild is called after the build process is finished.

func (*GRPCServer) OnPreBuild

OnPreBuild is called before the build process starts.

func (*GRPCServer) OnPublicAssetsCopied

OnPublicAssetsCopied is called after the public assets are copied.

func (*GRPCServer) ProcessAsset

func (m *GRPCServer) ProcessAsset(ctx context.Context, req *proto.Asset) (*proto.Asset, error)

ProcessAsset is called to process an asset with a custom pipeline.

func (*GRPCServer) RegisterPipelines

RegisterPipelines is called to register custom pipelines.

type Plugin

type Plugin interface {
	// Name returns the name of the plugin.
	Name() string
	// OnPreBuild is called before the build process starts.
	OnPreBuild() error
	// OnConfigLoaded is called after the configuration is loaded.
	OnConfigLoaded(config []byte) ([]byte, error)
	// OnPublicAssetsCopied is called after the public assets are copied.
	OnPublicAssetsCopied() error
	// OnContentLoaded is called after a content file is loaded.
	OnContentLoaded(path string, content []byte) ([]byte, error)
	// OnContentRender is called after a content file is rendered.
	OnContentRender(path string, content []byte) ([]byte, error)
	// OnHTMLRendered is called after the HTML is rendered.
	OnHTMLRendered(path string, content []byte) ([]byte, error)
	// OnPostBuild is called after the build process is finished.
	OnPostBuild() error
	// RegisterPipelines is called to register custom pipelines.
	RegisterPipelines() ([]*proto.Pipeline, error)
	// ProcessAsset is called to process an asset with a custom pipeline.
	ProcessAsset(asset *proto.Asset) (*proto.Asset, error)
}

Plugin is the interface that all evoke plugins must implement.

func LoadPlugins

func LoadPlugins() ([]Plugin, error)

LoadPlugins loads all the plugins in the plugins directory.

Jump to

Keyboard shortcuts

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