core

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

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

View Source
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 New

func New(metrics Metrics, registry Registry) *Core

New creates a new Core instance.

func (*Core) Generate

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

type PluginFilter struct {
	Group   string
	Name    string
	Version string
}

PluginFilter represents a filter for listing plugins.

type PluginInfo

type PluginInfo struct {
	ID        uuid.UUID
	Group     string
	Name      string
	Version   string
	CreatedAt time.Time
}

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.

Jump to

Keyboard shortcuts

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