Documentation
¶
Index ¶
- Constants
- func Merge(bp *schema.Blueprint, manifest *HandlerManifest, logger *zap.Logger) (*schema.Blueprint, error)
- func ValidateManifest(m *HandlerManifest) error
- func WriteMerged(bp *schema.Blueprint, format schema.SpecFormat, outputDir string) (string, error)
- func WriteMergedWithMode(bp *schema.Blueprint, format schema.SpecFormat, outputDir string, ...) (string, error)
- type ClassHandler
- type Extractor
- type ExtractorConfig
- type FunctionHandler
- type GuardHandler
- type HandlerManifest
- type HandlerSpec
Constants ¶
const ( ManifestVersion = "1" ManifestVersionGoSDK = "v1" )
ManifestVersion is the handler manifest format this package reads.
Accepted in two spellings. The Celerity Go SDK emits "v1" while the CLI's own no-extraction fallback constructs "1", and both have been in the wild unvalidated. Rejecting either now would break working projects to enforce a distinction that never meant anything.
Variables ¶
This section is empty.
Functions ¶
func Merge ¶
func Merge( bp *schema.Blueprint, manifest *HandlerManifest, logger *zap.Logger, ) (*schema.Blueprint, error)
Merge enriches a blueprint with extracted handler metadata. For each handler in the manifest:
- If a matching resource exists (by resource name): fill in missing annotations and spec
- If no matching resource exists: create a new handler resource
func ValidateManifest ¶
func ValidateManifest(m *HandlerManifest) error
ValidateManifest reports whether a handler manifest can be merged into a blueprint.
Worth checking for an extractor the CLI does not ship. A community SDK hand-produces this document and the merge is forgiving by design, skipping what it does not recognise. A manifest with the wrong annotation keys, or handlers with no resource name, therefore merges cleanly and produces an application with no handlers at all, surfacing as a runtime handshake failure a long way from the mistake.
func WriteMerged ¶
func WriteMerged( bp *schema.Blueprint, format schema.SpecFormat, outputDir string, ) (string, error)
WriteMerged serializes the blueprint to the staging location. The output format matches the original blueprint format.
func WriteMergedWithMode ¶
func WriteMergedWithMode( bp *schema.Blueprint, format schema.SpecFormat, outputDir string, mode os.FileMode, ) (string, error)
WriteMergedWithMode is WriteMerged with the file permissions stated.
A separate entry point because the two callers need different modes. A dev session's merged blueprint is ordinary generated output, while a deploy's carries the environment's configuration values, secrets among them, seeded so a first deploy can stand its store up, and that one must not be world readable.
Types ¶
type ClassHandler ¶
type ClassHandler struct {
ResourceName string `json:"resourceName"`
ClassName string `json:"className"`
MethodName string `json:"methodName"`
SourceFile string `json:"sourceFile"`
HandlerType string `json:"handlerType"` // "http", "websocket", "consumer", "schedule"
Annotations map[string]any `json:"annotations"`
Spec HandlerSpec `json:"spec"`
}
ClassHandler describes a handler discovered from a class-based decorator (e.g. @Controller + @Get in the Node.js SDK).
type Extractor ¶
type Extractor struct {
// contains filtered or unexported fields
}
Extractor invokes the language-specific CLI to scan developer code and produce a HandlerManifest describing all discovered handlers.
func NewExtractor ¶
func NewExtractor(config ExtractorConfig, logger *zap.Logger) *Extractor
NewExtractor creates an Extractor with the given config.
type ExtractorConfig ¶
type ExtractorConfig struct {
Runtime string // e.g. "nodejs22.x"
ModulePath string // e.g. "src/app-module.ts"
ProjectRoot string // Absolute path to the project directory
}
ExtractorConfig configures the language-specific handler extraction CLI.
type FunctionHandler ¶
type FunctionHandler struct {
ResourceName string `json:"resourceName"`
ExportName string `json:"exportName"`
SourceFile string `json:"sourceFile"`
Annotations map[string]any `json:"annotations,omitempty"`
Spec HandlerSpec `json:"spec"`
}
FunctionHandler describes a handler discovered from a function-based export.
type GuardHandler ¶
type GuardHandler struct {
ResourceName string `json:"resourceName"`
GuardName string `json:"guardName"`
SourceFile string `json:"sourceFile"`
GuardType string `json:"guardType"` // "class" or "function"
ClassName string `json:"className,omitempty"`
ExportName string `json:"exportName,omitempty"`
Annotations map[string]any `json:"annotations"`
Spec HandlerSpec `json:"spec"`
}
GuardHandler describes a custom auth guard discovered from a @Guard decorator or a function-based guard export.
type HandlerManifest ¶
type HandlerManifest struct {
Version string `json:"version"`
Handlers []ClassHandler `json:"handlers"`
FunctionHandlers []FunctionHandler `json:"functionHandlers"`
GuardHandlers []GuardHandler `json:"guardHandlers"`
}
HandlerManifest is the output of the language-specific extraction CLI, matching the handler-manifest.v1.schema.json format.
func CollapseRoutedConsumers ¶
func CollapseRoutedConsumers(manifest *HandlerManifest, logger *zap.Logger) *HandlerManifest
CollapseRoutedConsumers replaces the per-method handler resources of a routed consumer with a single resource for the consumer as a whole.
Extraction produces one handler resource per @MessageHandler, which a deploy target turns into one function each, and for a consumer that is wrong. Every one of those functions consumes the same queue and the source hands each message to whichever function polls first, so the declared routing key never applies and messages are processed by an arbitrary handler. Nothing reports it, because a handler that receives a message it was not routed cannot tell the difference.
Collapsing here rather than in the deploy target keeps one handler resource to one function everywhere downstream. The runtime routes the batch in-process, which it can do because every handler is in the same bundle.
The operation is idempotent, since a manifest that has already been collapsed has one handler per consumer and is returned unchanged.
func (*HandlerManifest) AllHandlers ¶
func (m *HandlerManifest) AllHandlers() int
AllHandlers returns a combined count of class, function, and guard handlers.
func (*HandlerManifest) Equal ¶
func (m *HandlerManifest) Equal(other *HandlerManifest) bool
Equal compares two manifests by handler count and resource names to detect structural changes that require a container restart.