Documentation
¶
Overview ¶
Package services implements the driving port interfaces. Services contain the core business logic and orchestrate calls to driven ports (adapters).
Services are pure Go with no CGO or external dependencies.
Index ¶
- Variables
- func FindAvailablePort(startPort, endPort int) (int, error)
- type AuthProviderService
- func (s *AuthProviderService) Delete(ctx context.Context, id string) error
- func (s *AuthProviderService) Get(ctx context.Context, id string) (*domain.AuthProvider, error)
- func (s *AuthProviderService) List(ctx context.Context) ([]domain.AuthProvider, error)
- func (s *AuthProviderService) ListByProvider(ctx context.Context, providerType domain.ProviderType) ([]domain.AuthProvider, error)
- func (s *AuthProviderService) Save(ctx context.Context, provider domain.AuthProvider) error
- type ConnectorRegistry
- func (r *ConnectorRegistry) BuildAuthURL(connectorType string, authProvider *domain.AuthProvider, ...) (string, error)
- func (r *ConnectorRegistry) ExchangeCode(ctx context.Context, connectorType string, authProvider *domain.AuthProvider, ...) (*domain.OAuthToken, error)
- func (r *ConnectorRegistry) Get(id string) (*domain.ConnectorType, error)
- func (r *ConnectorRegistry) GetConnectorsForProvider(provider domain.ProviderType) []domain.ConnectorType
- func (r *ConnectorRegistry) GetOAuthDefaults(connectorType string) *driving.OAuthDefaults
- func (r *ConnectorRegistry) GetSetupHint(connectorType string) string
- func (r *ConnectorRegistry) GetUserInfo(ctx context.Context, connectorType string, accessToken string) (string, error)
- func (r *ConnectorRegistry) List() []domain.ConnectorType
- func (r *ConnectorRegistry) SupportsOAuth(connectorType string) bool
- func (r *ConnectorRegistry) ValidateConfig(connectorID string, config map[string]string) error
- type CredentialsService
- func (s *CredentialsService) Delete(ctx context.Context, id string) error
- func (s *CredentialsService) Get(ctx context.Context, id string) (*domain.Credentials, error)
- func (s *CredentialsService) GetBySourceID(ctx context.Context, sourceID string) (*domain.Credentials, error)
- func (s *CredentialsService) Save(ctx context.Context, creds domain.Credentials) error
- type DocumentService
- func (s *DocumentService) Exclude(ctx context.Context, documentID, reason string) error
- func (s *DocumentService) Get(ctx context.Context, documentID string) (*domain.Document, error)
- func (s *DocumentService) GetContent(ctx context.Context, documentID string) (string, error)
- func (s *DocumentService) GetDetails(ctx context.Context, documentID string) (*driving.DocumentDetails, error)
- func (s *DocumentService) ListBySource(ctx context.Context, sourceID string) ([]domain.Document, error)
- func (s *DocumentService) Open(ctx context.Context, documentID string) error
- func (s *DocumentService) Refresh(_ context.Context, _ string) error
- type ProviderRegistry
- func (r *ProviderRegistry) GetAuthCapability(provider domain.ProviderType) domain.AuthCapability
- func (r *ProviderRegistry) GetConnectorsForProvider(provider domain.ProviderType) []string
- func (r *ProviderRegistry) GetDefaultAuthMethod(provider domain.ProviderType) domain.AuthMethod
- func (r *ProviderRegistry) GetOAuthEndpoints(provider domain.ProviderType) *driving.OAuthEndpoints
- func (r *ProviderRegistry) GetProviderForConnector(connectorType string) (domain.ProviderType, error)
- func (r *ProviderRegistry) GetProviders() []domain.ProviderType
- func (r *ProviderRegistry) GetSupportedAuthMethods(provider domain.ProviderType) []domain.AuthMethod
- func (r *ProviderRegistry) HasMultipleConnectors(provider domain.ProviderType) bool
- func (r *ProviderRegistry) IsCompatible(provider domain.ProviderType, connectorType string) bool
- func (r *ProviderRegistry) SupportsMultipleAuthMethods(provider domain.ProviderType) bool
- type ResultActionService
- type Scheduler
- type SearchService
- type SettingsService
- func (s *SettingsService) Get() (*domain.AppSettings, error)
- func (s *SettingsService) GetDefaults() domain.AppSettings
- func (s *SettingsService) GetPipelineConfig() domain.PipelineConfig
- func (s *SettingsService) GetSchedulerConfig() domain.SchedulerConfig
- func (s *SettingsService) RequiresEmbedding() bool
- func (s *SettingsService) RequiresLLM() bool
- func (s *SettingsService) Save(settings *domain.AppSettings) error
- func (s *SettingsService) SetEmbeddingProvider(provider domain.AIProvider, model, apiKey string) error
- func (s *SettingsService) SetLLMProvider(provider domain.AIProvider, model, apiKey string) error
- func (s *SettingsService) SetSearchMode(mode domain.SearchMode) error
- func (s *SettingsService) Validate() error
- func (s *SettingsService) ValidateEmbeddingConfig() error
- func (s *SettingsService) ValidateLLMConfig() error
- type SourceService
- func (s *SourceService) Add(ctx context.Context, source domain.Source) error
- func (s *SourceService) Get(ctx context.Context, id string) (*domain.Source, error)
- func (s *SourceService) List(ctx context.Context) ([]domain.Source, error)
- func (s *SourceService) Remove(ctx context.Context, id string) error
- func (s *SourceService) SetConnectorRegistry(registry driving.ConnectorRegistry)
- func (s *SourceService) Update(ctx context.Context, source domain.Source) error
- func (s *SourceService) ValidateConfig(_ context.Context, connectorType string, config map[string]string) error
- type SyncOrchestrator
Constants ¶
This section is empty.
Variables ¶
var ErrRefreshNotImplemented = errors.New("document refresh not yet implemented")
Sentinel errors for stub implementations.
Functions ¶
func FindAvailablePort ¶
FindAvailablePort finds an available port in the given range.
Types ¶
type AuthProviderService ¶
type AuthProviderService struct {
// contains filtered or unexported fields
}
AuthProviderService manages authentication provider configurations.
func NewAuthProviderService ¶
func NewAuthProviderService(store driven.AuthProviderStore, sourceStore driven.SourceStore) *AuthProviderService
NewAuthProviderService creates a new auth provider service.
func (*AuthProviderService) Delete ¶
func (s *AuthProviderService) Delete(ctx context.Context, id string) error
Delete removes an auth provider. Returns an error if the provider is still in use by any source.
func (*AuthProviderService) Get ¶
func (s *AuthProviderService) Get(ctx context.Context, id string) (*domain.AuthProvider, error)
Get retrieves an auth provider by ID.
func (*AuthProviderService) List ¶
func (s *AuthProviderService) List(ctx context.Context) ([]domain.AuthProvider, error)
List returns all auth providers.
func (*AuthProviderService) ListByProvider ¶
func (s *AuthProviderService) ListByProvider( ctx context.Context, providerType domain.ProviderType, ) ([]domain.AuthProvider, error)
ListByProvider returns auth providers for a specific provider type.
func (*AuthProviderService) Save ¶
func (s *AuthProviderService) Save(ctx context.Context, provider domain.AuthProvider) error
Save creates or updates an auth provider.
type ConnectorRegistry ¶
type ConnectorRegistry struct {
// contains filtered or unexported fields
}
ConnectorRegistry provides information about available connector types.
func NewConnectorRegistry ¶
func NewConnectorRegistry(connectorFactory driven.ConnectorFactory) *ConnectorRegistry
NewConnectorRegistry creates a new connector registry with built-in connectors.
func (*ConnectorRegistry) BuildAuthURL ¶
func (r *ConnectorRegistry) BuildAuthURL( connectorType string, authProvider *domain.AuthProvider, redirectURI, state, codeChallenge string, ) (string, error)
BuildAuthURL constructs the OAuth authorization URL for a connector type. Includes provider-specific parameters (e.g., access_type=offline for Google).
func (*ConnectorRegistry) ExchangeCode ¶ added in v0.2.3
func (r *ConnectorRegistry) ExchangeCode( ctx context.Context, connectorType string, authProvider *domain.AuthProvider, code, redirectURI, codeVerifier string, ) (*domain.OAuthToken, error)
ExchangeCode exchanges an authorization code for tokens using connector-specific logic.
func (*ConnectorRegistry) Get ¶
func (r *ConnectorRegistry) Get(id string) (*domain.ConnectorType, error)
Get returns a specific connector type by ID.
func (*ConnectorRegistry) GetConnectorsForProvider ¶ added in v0.2.3
func (r *ConnectorRegistry) GetConnectorsForProvider(provider domain.ProviderType) []domain.ConnectorType
GetConnectorsForProvider returns all connector types for a given provider.
func (*ConnectorRegistry) GetOAuthDefaults ¶
func (r *ConnectorRegistry) GetOAuthDefaults(connectorType string) *driving.OAuthDefaults
GetOAuthDefaults returns default OAuth URLs and scopes for a connector type. Returns nil if the connector type doesn't support OAuth.
func (*ConnectorRegistry) GetSetupHint ¶
func (r *ConnectorRegistry) GetSetupHint(connectorType string) string
GetSetupHint returns guidance text for setting up OAuth/PAT with a provider.
func (*ConnectorRegistry) GetUserInfo ¶
func (r *ConnectorRegistry) GetUserInfo( ctx context.Context, connectorType string, accessToken string, ) (string, error)
GetUserInfo fetches the account identifier (email/username) for a connector type.
func (*ConnectorRegistry) List ¶
func (r *ConnectorRegistry) List() []domain.ConnectorType
List returns all available connector types.
func (*ConnectorRegistry) SupportsOAuth ¶
func (r *ConnectorRegistry) SupportsOAuth(connectorType string) bool
SupportsOAuth returns true if the connector type supports OAuth authentication.
func (*ConnectorRegistry) ValidateConfig ¶
func (r *ConnectorRegistry) ValidateConfig(connectorID string, config map[string]string) error
ValidateConfig validates configuration for a connector type.
type CredentialsService ¶
type CredentialsService struct {
// contains filtered or unexported fields
}
CredentialsService manages user-specific authentication credentials.
func NewCredentialsService ¶
func NewCredentialsService(store driven.CredentialsStore) *CredentialsService
NewCredentialsService creates a new credentials service.
func (*CredentialsService) Delete ¶
func (s *CredentialsService) Delete(ctx context.Context, id string) error
Delete removes credentials by ID.
func (*CredentialsService) Get ¶
func (s *CredentialsService) Get(ctx context.Context, id string) (*domain.Credentials, error)
Get retrieves credentials by ID.
func (*CredentialsService) GetBySourceID ¶
func (s *CredentialsService) GetBySourceID(ctx context.Context, sourceID string) (*domain.Credentials, error)
GetBySourceID retrieves credentials for a specific source.
func (*CredentialsService) Save ¶
func (s *CredentialsService) Save(ctx context.Context, creds domain.Credentials) error
Save creates or updates credentials.
type DocumentService ¶
type DocumentService struct {
// contains filtered or unexported fields
}
DocumentService manages documents within sources.
func NewDocumentService ¶
func NewDocumentService( docStore driven.DocumentStore, sourceStore driven.SourceStore, exclusionStore driven.ExclusionStore, connectorRegistry driving.ConnectorRegistry, ) *DocumentService
NewDocumentService creates a new document service.
func (*DocumentService) Exclude ¶
func (s *DocumentService) Exclude(ctx context.Context, documentID, reason string) error
Exclude removes a document and marks it to skip during re-sync.
func (*DocumentService) GetContent ¶
GetContent returns the concatenated content of all chunks.
func (*DocumentService) GetDetails ¶
func (s *DocumentService) GetDetails(ctx context.Context, documentID string) (*driving.DocumentDetails, error)
GetDetails returns connector-agnostic metadata for display.
func (*DocumentService) ListBySource ¶
func (s *DocumentService) ListBySource(ctx context.Context, sourceID string) ([]domain.Document, error)
ListBySource returns all documents for a source.
type ProviderRegistry ¶
type ProviderRegistry struct {
// contains filtered or unexported fields
}
ProviderRegistry provides information about providers and their compatible connectors. It derives all provider information from the registered connectors, ensuring no hardcoded provider knowledge exists in this service.
func NewProviderRegistry ¶
func NewProviderRegistry( connectorRegistry driving.ConnectorRegistry, connectorFactory driven.ConnectorFactory, ) *ProviderRegistry
NewProviderRegistry creates a new ProviderRegistry. Both dependencies are required for full functionality but can be nil for limited use.
func (*ProviderRegistry) GetAuthCapability ¶
func (r *ProviderRegistry) GetAuthCapability(provider domain.ProviderType) domain.AuthCapability
GetAuthCapability returns the authentication capabilities for a provider. Derives this from the first connector registered for the provider.
func (*ProviderRegistry) GetConnectorsForProvider ¶
func (r *ProviderRegistry) GetConnectorsForProvider(provider domain.ProviderType) []string
GetConnectorsForProvider returns connector types compatible with a provider.
func (*ProviderRegistry) GetDefaultAuthMethod ¶
func (r *ProviderRegistry) GetDefaultAuthMethod(provider domain.ProviderType) domain.AuthMethod
GetDefaultAuthMethod returns the typical auth method for a provider. For providers supporting multiple methods, returns the recommended default.
func (*ProviderRegistry) GetOAuthEndpoints ¶
func (r *ProviderRegistry) GetOAuthEndpoints(provider domain.ProviderType) *driving.OAuthEndpoints
GetOAuthEndpoints returns the OAuth endpoints for a provider. Delegates to the connector factory to get default OAuth config from the connector's OAuthHandler.
func (*ProviderRegistry) GetProviderForConnector ¶
func (r *ProviderRegistry) GetProviderForConnector(connectorType string) (domain.ProviderType, error)
GetProviderForConnector returns the provider type for a connector.
func (*ProviderRegistry) GetProviders ¶
func (r *ProviderRegistry) GetProviders() []domain.ProviderType
GetProviders returns all available provider types. Derives the list from registered connectors.
func (*ProviderRegistry) GetSupportedAuthMethods ¶
func (r *ProviderRegistry) GetSupportedAuthMethods(provider domain.ProviderType) []domain.AuthMethod
GetSupportedAuthMethods returns all auth methods supported by a provider.
func (*ProviderRegistry) HasMultipleConnectors ¶
func (r *ProviderRegistry) HasMultipleConnectors(provider domain.ProviderType) bool
HasMultipleConnectors returns true if the provider supports multiple distinct connectors that can share an OAuth app. For example, Google has Drive, Gmail, Calendar as separate connectors that can share the same OAuth app credentials.
func (*ProviderRegistry) IsCompatible ¶
func (r *ProviderRegistry) IsCompatible(provider domain.ProviderType, connectorType string) bool
IsCompatible checks if a connector can use a provider.
func (*ProviderRegistry) SupportsMultipleAuthMethods ¶
func (r *ProviderRegistry) SupportsMultipleAuthMethods(provider domain.ProviderType) bool
SupportsMultipleAuthMethods returns true if the provider supports choosing between auth methods.
type ResultActionService ¶
type ResultActionService struct {
// contains filtered or unexported fields
}
ResultActionService provides actions on search results.
func NewResultActionService ¶
func NewResultActionService( sourceStore driven.SourceStore, connectorRegistry driving.ConnectorRegistry, ) *ResultActionService
NewResultActionService creates a new result action service.
func (*ResultActionService) CopyToClipboard ¶
func (s *ResultActionService) CopyToClipboard(_ context.Context, result *domain.SearchResult) error
CopyToClipboard copies the result's content to the system clipboard.
func (*ResultActionService) OpenDocument ¶
func (s *ResultActionService) OpenDocument(ctx context.Context, result *domain.SearchResult) error
OpenDocument opens the result's document in the default application.
type Scheduler ¶
type Scheduler struct {
// contains filtered or unexported fields
}
Scheduler manages background task execution. It is a pure core service with no external control API.
func NewScheduler ¶
func NewScheduler( config domain.SchedulerConfig, store driven.SchedulerStore, syncOrch driving.SyncOrchestrator, ) *Scheduler
NewScheduler creates a scheduler with configuration.
type SearchService ¶
type SearchService struct {
// contains filtered or unexported fields
}
SearchService provides hybrid search functionality.
func NewSearchService ¶
func NewSearchService( docStore driven.DocumentStore, searchIndex driven.SearchEngine, vectorIndex driven.VectorIndex, embeddingService driven.EmbeddingService, llmService driven.LLMService, ) *SearchService
NewSearchService creates a new search service. The embeddingService and llmService parameters are optional (can be nil).
func (*SearchService) Search ¶
func (s *SearchService) Search( ctx context.Context, query string, opts domain.SearchOptions, ) ([]domain.SearchResult, error)
Search performs hybrid search across all indexed documents.
func (*SearchService) SetCredentialsStore ¶
func (s *SearchService) SetCredentialsStore(store driven.CredentialsStore)
SetCredentialsStore sets the credentials store for SourceName enrichment.
func (*SearchService) SetSourceStore ¶
func (s *SearchService) SetSourceStore(store driven.SourceStore)
SetSourceStore sets the source store for SourceName enrichment.
type SettingsService ¶
type SettingsService struct {
// contains filtered or unexported fields
}
SettingsService manages application settings.
func NewSettingsService ¶
func NewSettingsService(configStore driven.ConfigStore, aiValidator driven.AIConfigValidator) *SettingsService
NewSettingsService creates a new settings service.
func (*SettingsService) Get ¶
func (s *SettingsService) Get() (*domain.AppSettings, error)
Get retrieves current application settings.
func (*SettingsService) GetDefaults ¶
func (s *SettingsService) GetDefaults() domain.AppSettings
GetDefaults returns default settings.
func (*SettingsService) GetPipelineConfig ¶
func (s *SettingsService) GetPipelineConfig() domain.PipelineConfig
GetPipelineConfig returns the post-processor pipeline configuration. Returns default configuration if nothing is configured.
func (*SettingsService) GetSchedulerConfig ¶
func (s *SettingsService) GetSchedulerConfig() domain.SchedulerConfig
GetSchedulerConfig returns the scheduler configuration. Returns default configuration if nothing is configured.
func (*SettingsService) RequiresEmbedding ¶
func (s *SettingsService) RequiresEmbedding() bool
RequiresEmbedding returns true if current mode needs embedding.
func (*SettingsService) RequiresLLM ¶
func (s *SettingsService) RequiresLLM() bool
RequiresLLM returns true if current mode needs LLM.
func (*SettingsService) Save ¶
func (s *SettingsService) Save(settings *domain.AppSettings) error
Save persists application settings.
func (*SettingsService) SetEmbeddingProvider ¶
func (s *SettingsService) SetEmbeddingProvider(provider domain.AIProvider, model, apiKey string) error
SetEmbeddingProvider configures the embedding provider.
func (*SettingsService) SetLLMProvider ¶
func (s *SettingsService) SetLLMProvider(provider domain.AIProvider, model, apiKey string) error
SetLLMProvider configures the LLM provider.
func (*SettingsService) SetSearchMode ¶
func (s *SettingsService) SetSearchMode(mode domain.SearchMode) error
SetSearchMode updates the search mode.
func (*SettingsService) Validate ¶
func (s *SettingsService) Validate() error
Validate checks if current settings are valid for the configured mode.
func (*SettingsService) ValidateEmbeddingConfig ¶
func (s *SettingsService) ValidateEmbeddingConfig() error
ValidateEmbeddingConfig validates the current embedding configuration by pinging the provider.
func (*SettingsService) ValidateLLMConfig ¶
func (s *SettingsService) ValidateLLMConfig() error
ValidateLLMConfig validates the current LLM configuration by pinging the provider.
type SourceService ¶
type SourceService struct {
// contains filtered or unexported fields
}
SourceService manages source configurations.
func NewSourceService ¶
func NewSourceService( sourceStore driven.SourceStore, syncStore driven.SyncStateStore, docStore driven.DocumentStore, ) *SourceService
NewSourceService creates a new source service.
func (*SourceService) Remove ¶
func (s *SourceService) Remove(ctx context.Context, id string) error
Remove deletes a source and its indexed data.
func (*SourceService) SetConnectorRegistry ¶
func (s *SourceService) SetConnectorRegistry(registry driving.ConnectorRegistry)
SetConnectorRegistry sets the connector registry for config validation.
func (*SourceService) ValidateConfig ¶
func (s *SourceService) ValidateConfig(_ context.Context, connectorType string, config map[string]string) error
ValidateConfig validates source configuration for a connector type.
type SyncOrchestrator ¶
type SyncOrchestrator struct {
// contains filtered or unexported fields
}
SyncOrchestrator coordinates document synchronisation.
func NewSyncOrchestrator ¶
func NewSyncOrchestrator( sourceStore driven.SourceStore, syncStore driven.SyncStateStore, docStore driven.DocumentStore, exclusionStore driven.ExclusionStore, factory driven.ConnectorFactory, registry driven.NormaliserRegistry, pipeline driven.PostProcessorPipeline, searchIndex driven.SearchEngine, vectorIndex driven.VectorIndex, embeddingService driven.EmbeddingService, ) *SyncOrchestrator
NewSyncOrchestrator creates a new sync orchestrator. The searchIndex, vectorIndex and embeddingService are used when creating Indexers for sync. VectorIndex and embeddingService are optional - if nil, semantic indexing is disabled.
func (*SyncOrchestrator) Status ¶
func (o *SyncOrchestrator) Status(_ context.Context, sourceID string) (*driving.SyncStatus, error)
Status returns sync status for a source.