Documentation
¶
Overview ¶
Package core contains the core implementation of the business logic.
Package core contains the domain types and interfaces for the plugin server.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("not found") ErrInvalidPluginName = errors.New("invalid plugin name") ErrGenerationFailed = errors.New("code generation failed") )
Errors.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core defines the interface for interacting with the plugin server.
func (*Core) Generate ¶
func (c *Core) Generate(ctx context.Context, req GenerateCodeRequest) (*GenerateCodeResponse, error)
Generate generates code by plugin.
func (*Core) ListPlugins ¶
func (c *Core) ListPlugins(ctx context.Context, filter PluginFilter) ([]PluginInfo, error)
ListPlugins retrieves a list of plugins matching the filter.
type GenerateCodeRequest ¶
type GenerateCodeRequest struct {
// PluginName identifies the plugin to use for code generation.
// Format: "<language>:v<version>" (e.g., "go:v1.36.9", "python:v3.20.0").
PluginName string
// Payload contains the protobuf code generation request with source files and parameters.
Payload *pluginpb.CodeGeneratorRequest
}
GenerateCodeRequest represents an incoming request to generate code using a specific plugin.
type GenerateCodeResponse ¶
type GenerateCodeResponse struct {
// Payload contains the protobuf code generation response with generated files.
Payload *pluginpb.CodeGeneratorResponse
}
GenerateCodeResponse wraps the response from a code generation operation.
type Metrics ¶
type Metrics interface {
// GenerateCode records metrics for a code generation request.
// The pluginName parameter identifies which plugin was used (e.g., "grpc/go:v1.36.9").
GenerateCode(ctx context.Context, info PluginInfo) error
}
Metrics defines the interface for collecting metrics about core operations.
type Plugin ¶
type Plugin interface {
// Generate processes a code generation request and produces generated code.
// Takes a protobuf CodeGeneratorRequest and returns a CodeGeneratorResponse
// containing the generated files or an error if generation fails.
Generate(ctx context.Context, req *pluginpb.CodeGeneratorRequest) (*pluginpb.CodeGeneratorResponse, error)
// Info retrieves information about a plugin by its identifier.
Info(ctx context.Context) *PluginInfo
}
Plugin represents a code generator plugin that processes protobuf definitions.
type PluginFilter ¶
PluginFilter represents a filter for listing plugins.
type PluginInfo ¶
PluginInfo represents information about a plugin.
type Registry ¶
type Registry interface {
// Get retrieves a plugin by its identifier.
// The pluginName parameter specifies the plugin to retrieve (e.g., "protobuf/go:v1.36.9").
// Returns an error if the plugin is not found or cannot be loaded.
Get(ctx context.Context, pluginGroup, pluginName, pluginVersion string) (Plugin, error)
// List retrieves a list of plugins matching the filter.
List(ctx context.Context, filter PluginFilter) ([]PluginInfo, error)
}
Registry provides access to available plugins.