Documentation
¶
Overview ¶
Package processor provides implementations for different response processors
Package processor provides response processing functionality for CronAI.
Package processor provides functionality for processing model responses through various output channels
Index ¶
- Constants
- func FormatGitHubMessage(messageType string, data template.Data) string
- func GetEnvWithDefault(key, defaultValue string) string
- func GetProcessorFunc(config Config) func() (Processor, error)
- func GetWebhookHeaders(webhookType string) string
- func GetWebhookMethod(webhookType string) string
- func GetWebhookURL(webhookType string) string
- func InitTemplates(templateDir string) error
- func ProcessResponse(processorName string, response *models.ModelResponse, templateName string) error
- func SetLogger(l *logger.Logger)
- type Config
- type ConsoleProcessor
- type EmailProcessor
- type Factory
- type FileProcessor
- type GitHubProcessor
- type Options
- type Processor
- func CreateProcessor(processorType string, config Config) (Processor, error)
- func GetProcessor(config Config) (Processor, error)
- func NewConsoleProcessor(config Config) (Processor, error)
- func NewEmailProcessor(config Config) (Processor, error)
- func NewFileProcessor(config Config) (Processor, error)
- func NewGitHubProcessor(config Config) (Processor, error)
- func NewSlackProcessor(config Config) (Processor, error)
- func NewWebhookProcessor(config Config) (Processor, error)
- type Registry
- func (r *Registry) CreateProcessor(processorType string, config Config) (Processor, error)
- func (r *Registry) GetProcessorTypes() []string
- func (r *Registry) RegisterDefaults()
- func (r *Registry) RegisterFactory(processorType string, factory Factory)
- func (r *Registry) RegisterProcessor(processorType string, factory Factory)
- type SlackProcessor
- type WebhookProcessor
Constants ¶
const ( // Slack processor environment variables EnvSlackToken = "SLACK_TOKEN" // Email processor environment variables EnvSMTPServer = "SMTP_SERVER" EnvSMTPPort = "SMTP_PORT" EnvSMTPUser = "SMTP_USER" EnvSMTPPassword = "SMTP_PASSWORD" EnvSMTPFrom = "SMTP_FROM" // Webhook processor environment variables EnvWebhookURL = "WEBHOOK_URL" EnvWebhookMethod = "WEBHOOK_METHOD" EnvWebhookHeaders = "WEBHOOK_HEADERS" // Dynamic webhook environment variables (use with strings.ToUpper) EnvWebhookURLPrefix = "WEBHOOK_URL_" EnvWebhookMethodPrefix = "WEBHOOK_METHOD_" EnvWebhookHeadersPrefix = "WEBHOOK_HEADERS_" // File processor environment variables EnvLogsDirectory = "LOGS_DIRECTORY" // GitHub processor environment variables EnvGitHubToken = "GITHUB_TOKEN" // Default values DefaultSMTPPort = "587" DefaultWebhookMethod = "POST" DefaultLogsDirectory = "logs" )
Environment variable names for processors
Variables ¶
This section is empty.
Functions ¶
func FormatGitHubMessage ¶
FormatGitHubMessage formats a message for GitHub (issue, PR, comment) with a consistent structure This avoids duplication of formatting logic across different GitHub operations
func GetEnvWithDefault ¶
GetEnvWithDefault returns the value of the environment variable or a default value
func GetProcessorFunc ¶
GetProcessorFunc returns a function that creates a processor
func GetWebhookHeaders ¶
GetWebhookHeaders returns the webhook headers for a specific type or the default
func GetWebhookMethod ¶
GetWebhookMethod returns the webhook method for a specific type or the default
func GetWebhookURL ¶
GetWebhookURL returns the webhook URL for a specific type or the default
func InitTemplates ¶
InitTemplates initializes the template system
func ProcessResponse ¶
func ProcessResponse(processorName string, response *models.ModelResponse, templateName string) error
ProcessResponse processes a model response using the specified processor
Types ¶
type Config ¶
type Config struct {
// Type identifies the processor type (email, slack, webhook, file, etc.)
Type string `json:"type"`
// Target specifies the destination (email address, webhook URL, file path, etc.)
Target string `json:"target"`
// Options contains processor-specific configuration
Options map[string]interface{} `json:"options,omitempty"`
// TemplateName specifies the template to use (optional)
TemplateName string `json:"template_name,omitempty"`
// Environment contains environment variable names used by the processor
Environment map[string]string `json:"environment,omitempty"`
}
Config represents standardized configuration for processors
type ConsoleProcessor ¶
type ConsoleProcessor struct {
// contains filtered or unexported fields
}
ConsoleProcessor handles console output
func (*ConsoleProcessor) GetConfig ¶
func (c *ConsoleProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*ConsoleProcessor) GetType ¶
func (c *ConsoleProcessor) GetType() string
GetType returns the processor type identifier
func (*ConsoleProcessor) Process ¶
func (c *ConsoleProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*ConsoleProcessor) Validate ¶
func (c *ConsoleProcessor) Validate() error
Validate checks if the processor is properly configured
type EmailProcessor ¶
type EmailProcessor struct {
// contains filtered or unexported fields
}
EmailProcessor handles email processing
func (*EmailProcessor) GetConfig ¶
func (e *EmailProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*EmailProcessor) GetType ¶
func (e *EmailProcessor) GetType() string
GetType returns the processor type identifier
func (*EmailProcessor) Process ¶
func (e *EmailProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*EmailProcessor) Validate ¶
func (e *EmailProcessor) Validate() error
Validate checks if the processor is properly configured
type FileProcessor ¶
type FileProcessor struct {
// contains filtered or unexported fields
}
FileProcessor handles file output
func (*FileProcessor) GetConfig ¶
func (f *FileProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*FileProcessor) GetType ¶
func (f *FileProcessor) GetType() string
GetType returns the processor type identifier
func (*FileProcessor) Process ¶
func (f *FileProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*FileProcessor) Validate ¶
func (f *FileProcessor) Validate() error
Validate checks if the processor is properly configured
type GitHubProcessor ¶
type GitHubProcessor struct {
// contains filtered or unexported fields
}
GitHubProcessor handles GitHub operations (issues, comments, pull requests)
func (*GitHubProcessor) GetConfig ¶
func (g *GitHubProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*GitHubProcessor) GetType ¶
func (g *GitHubProcessor) GetType() string
GetType returns the processor type identifier
func (*GitHubProcessor) Process ¶
func (g *GitHubProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*GitHubProcessor) Validate ¶
func (g *GitHubProcessor) Validate() error
Validate checks if the processor is properly configured
type Options ¶
type Options struct {
TemplateDir string // Directory containing custom templates
}
Options contains options for processors
type Processor ¶
type Processor interface {
// Process handles the model response with optional template
Process(response *models.ModelResponse, templateName string) error
// Validate checks if the processor is properly configured
Validate() error
// GetType returns the processor type identifier
GetType() string
// GetConfig returns the processor configuration
GetConfig() Config
}
Processor defines the interface for all response processors
func CreateProcessor ¶
CreateProcessor creates a new processor using the global registry
func GetProcessor ¶
GetProcessor creates a processor from the given config
func NewConsoleProcessor ¶
NewConsoleProcessor creates a new console processor
func NewEmailProcessor ¶
NewEmailProcessor creates a new email processor
func NewFileProcessor ¶
NewFileProcessor creates a new file processor
func NewGitHubProcessor ¶
NewGitHubProcessor creates a new GitHub processor
func NewSlackProcessor ¶
NewSlackProcessor creates a new Slack processor
func NewWebhookProcessor ¶
NewWebhookProcessor creates a new webhook processor
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry manages available processors
func (*Registry) CreateProcessor ¶
CreateProcessor creates a new processor instance
func (*Registry) GetProcessorTypes ¶
GetProcessorTypes returns all registered processor types
func (*Registry) RegisterDefaults ¶
func (r *Registry) RegisterDefaults()
RegisterDefaults registers all default processors
func (*Registry) RegisterFactory ¶
RegisterFactory registers a new processor factory
func (*Registry) RegisterProcessor ¶
RegisterProcessor registers a new processor factory
type SlackProcessor ¶
type SlackProcessor struct {
// contains filtered or unexported fields
}
SlackProcessor handles Slack messaging
func (*SlackProcessor) GetConfig ¶
func (s *SlackProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*SlackProcessor) GetType ¶
func (s *SlackProcessor) GetType() string
GetType returns the processor type identifier
func (*SlackProcessor) Process ¶
func (s *SlackProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*SlackProcessor) Validate ¶
func (s *SlackProcessor) Validate() error
Validate checks if the processor is properly configured
type WebhookProcessor ¶
type WebhookProcessor struct {
// contains filtered or unexported fields
}
WebhookProcessor handles webhook requests
func (*WebhookProcessor) GetConfig ¶
func (w *WebhookProcessor) GetConfig() Config
GetConfig returns the processor configuration
func (*WebhookProcessor) GetType ¶
func (w *WebhookProcessor) GetType() string
GetType returns the processor type identifier
func (*WebhookProcessor) Process ¶
func (w *WebhookProcessor) Process(response *models.ModelResponse, templateName string) error
Process handles the model response with optional template
func (*WebhookProcessor) Validate ¶
func (w *WebhookProcessor) Validate() error
Validate checks if the processor is properly configured