services

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAdminService

func NewAdminService(
	taskQueue driven.TaskQueue,
	schedulerStore driven.SchedulerStore,
	searchQueryRepository driven.SearchQueryRepository,
	sourceStore driven.SourceStore,
) driving.AdminService

NewAdminService creates a new AdminService

func NewAuthService

func NewAuthService(
	userStore driven.UserStore,
	sessionStore driven.SessionStore,
	authAdapter driven.AuthAdapter,
) driving.AuthService

NewAuthService creates a new AuthService

func NewCapabilitiesService

func NewCapabilitiesService(
	configProvider driven.ConfigProvider,
	capabilityStore driven.CapabilityStore,
) driving.CapabilitiesService

NewCapabilitiesService creates a new CapabilitiesService.

func NewConnectionService

func NewConnectionService(cfg ConnectionServiceConfig) driving.ConnectionService

NewConnectionService creates a new connection service.

func NewDocumentService

func NewDocumentService(
	documentStore driven.DocumentStore,
	chunkStore driven.ChunkStore,
) driving.DocumentService

NewDocumentService creates a new DocumentService

func NewOAuthService

func NewOAuthService(cfg OAuthServiceConfig) driving.OAuthService

NewOAuthService creates a new OAuth service.

func NewProviderService

func NewProviderService(configProvider driven.ConfigProvider) driving.ProviderService

NewProviderService creates a new ProviderService.

func NewSearchService

func NewSearchService(
	searchEngine driven.SearchEngine,
	documentStore driven.DocumentStore,
	services *runtime.Services,
	searchExecutor pipelineport.SearchExecutor,
	capabilityStore driven.CapabilityStore,
	settingsStore driven.SettingsStore,
	teamID string,
) driving.SearchService

NewSearchService creates a new SearchService AI services (embedding, LLM) are accessed dynamically via runtime.Services

func NewSettingsService

func NewSettingsService(
	settingsStore driven.SettingsStore,
	aiFactory driven.AIServiceFactory,
	configProvider driven.ConfigProvider,
	services *runtime.Services,
	teamID string,
) driving.SettingsService

NewSettingsService creates a new SettingsService

func NewSetupService

func NewSetupService(
	userStore driven.UserStore,
	sourceStore driven.SourceStore,
	teamID string,
) driving.SetupService

NewSetupService creates a new SetupService

func NewSourceService

func NewSourceService(
	sourceStore driven.SourceStore,
	documentStore driven.DocumentStore,
	syncStore driven.SyncStateStore,
	searchEngine driven.SearchEngine,
) driving.SourceService

NewSourceService creates a new SourceService

func NewUserService

func NewUserService(
	userStore driven.UserStore,
	sessionStore driven.SessionStore,
	authAdapter driven.AuthAdapter,
	teamID string,
) driving.UserService

NewUserService creates a new UserService

Types

type ConnectionServiceConfig

type ConnectionServiceConfig struct {
	// ConnectionStore manages connection persistence.
	ConnectionStore driven.ConnectionStore

	// SourceStore manages source persistence (for checking usage).
	SourceStore driven.SourceStore

	// ContainerListerFactory creates container listers for providers.
	ContainerListerFactory driven.ContainerListerFactory

	// TokenProviderFactory creates token providers for testing connections.
	TokenProviderFactory driven.TokenProviderFactory
}

ConnectionServiceConfig holds configuration for the connection service.

type OAuthServiceConfig

type OAuthServiceConfig struct {
	// ConfigProvider retrieves OAuth app credentials from environment variables.
	ConfigProvider driven.ConfigProvider

	// OAuthStateStore manages OAuth flow state.
	OAuthStateStore driven.OAuthStateStore

	// ConnectionStore persists connector installations.
	ConnectionStore driven.ConnectionStore

	// OAuthHandlerFactory provides OAuth handlers per provider.
	// Port interface - abstracts connector factory.
	OAuthHandlerFactory driven.OAuthHandlerFactory
}

OAuthServiceConfig holds configuration for the OAuth service.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler manages periodic task scheduling. It runs on worker nodes and enqueues tasks based on schedules.

For multi-worker deployments, configure a DistributedLock to prevent duplicate task enqueuing across instances.

func NewScheduler

func NewScheduler(cfg SchedulerConfig) *Scheduler

NewScheduler creates a new scheduler.

func (*Scheduler) CreateScheduledTask

func (s *Scheduler) CreateScheduledTask(ctx context.Context, scheduled *domain.ScheduledTask) error

CreateScheduledTask creates a new scheduled task.

func (*Scheduler) DeleteScheduledTask

func (s *Scheduler) DeleteScheduledTask(ctx context.Context, id string) error

DeleteScheduledTask deletes a scheduled task.

func (*Scheduler) DisableScheduledTask

func (s *Scheduler) DisableScheduledTask(ctx context.Context, id string) error

DisableScheduledTask disables a scheduled task.

func (*Scheduler) EnableScheduledTask

func (s *Scheduler) EnableScheduledTask(ctx context.Context, id string) error

EnableScheduledTask enables a scheduled task.

func (*Scheduler) GetScheduledTask

func (s *Scheduler) GetScheduledTask(ctx context.Context, id string) (*domain.ScheduledTask, error)

GetScheduledTask retrieves a scheduled task by ID.

func (*Scheduler) ListScheduledTasks

func (s *Scheduler) ListScheduledTasks(ctx context.Context, teamID string) ([]*domain.ScheduledTask, error)

ListScheduledTasks lists all scheduled tasks for a team.

func (*Scheduler) Start

func (s *Scheduler) Start(ctx context.Context) error

Start begins the scheduler loop. It runs until Stop is called or context is cancelled.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop gracefully stops the scheduler.

func (*Scheduler) TriggerNow

func (s *Scheduler) TriggerNow(ctx context.Context, id string) (*domain.Task, error)

TriggerNow immediately enqueues a scheduled task (ignoring schedule).

func (*Scheduler) UpdateScheduledTask

func (s *Scheduler) UpdateScheduledTask(ctx context.Context, scheduled *domain.ScheduledTask) error

UpdateScheduledTask updates a scheduled task.

type SchedulerConfig

type SchedulerConfig struct {
	Store        driven.SchedulerStore
	TaskQueue    driven.TaskQueue
	Lock         driven.DistributedLock // Optional: distributed lock for multi-instance coordination
	Logger       *slog.Logger
	PollInterval time.Duration // How often to check for due tasks (default: 30s)
	LockTTL      time.Duration // TTL for the distributed lock (default: 60s)
	LockRequired bool          // If true, skip scheduling when lock cannot be acquired (default: true)
}

SchedulerConfig holds configuration for the scheduler.

type SyncOrchestrator

type SyncOrchestrator struct {
	// contains filtered or unexported fields
}

SyncOrchestrator coordinates the document sync pipeline. It implements the 7-step sync flow:

  1. Get source config
  2. Create connector
  3. Validate connector
  4. Get sync state (cursor for incremental sync)
  5. Fetch documents
  6. Process each document (normalise → chunk → embed → store → index)
  7. Update sync cursor

func NewSyncOrchestrator

func NewSyncOrchestrator(cfg SyncOrchestratorConfig) *SyncOrchestrator

NewSyncOrchestrator creates a new sync orchestrator.

func (*SyncOrchestrator) CancelSync

func (o *SyncOrchestrator) CancelSync(ctx context.Context, sourceID string) error

CancelSync cancels an ongoing sync for a source. Note: This is a placeholder - actual cancellation requires context propagation.

func (*SyncOrchestrator) GetSyncState

func (o *SyncOrchestrator) GetSyncState(ctx context.Context, sourceID string) (*domain.SyncState, error)

GetSyncState retrieves the sync state for a source.

func (*SyncOrchestrator) ListSyncStates

func (o *SyncOrchestrator) ListSyncStates(ctx context.Context) ([]*domain.SyncState, error)

ListSyncStates retrieves sync states for all sources.

func (*SyncOrchestrator) SyncAll

func (o *SyncOrchestrator) SyncAll(ctx context.Context) ([]*domain.SyncResult, error)

SyncAll synchronizes all enabled sources for a team.

func (*SyncOrchestrator) SyncSource

func (o *SyncOrchestrator) SyncSource(ctx context.Context, sourceID string) (*domain.SyncResult, error)

SyncSource synchronizes a single source. This is the main entry point for the sync pipeline. For sources with container selection, it syncs each selected container.

type SyncOrchestratorConfig

type SyncOrchestratorConfig struct {
	SourceStore      driven.SourceStore
	DocumentStore    driven.DocumentStore
	ChunkStore       driven.ChunkStore
	SyncStore        driven.SyncStateStore
	SearchEngine     driven.SearchEngine
	VectorIndex      driven.VectorIndex
	ConnectorFactory driven.ConnectorFactory
	NormaliserReg    driven.NormaliserRegistry
	Services         *runtime.Services
	Logger           *slog.Logger
	IndexingExecutor pipelineport.IndexingExecutor // Required pipeline executor
	CapabilitySet    *pipeline.CapabilitySet       // Capabilities for pipeline
	CapabilityStore  driven.CapabilityStore        // For fetching capability preferences
	SettingsStore    driven.SettingsStore          // For loading team settings
	TeamID           string                        // Team ID for settings lookup
}

SyncOrchestratorConfig holds dependencies for SyncOrchestrator.

Jump to

Keyboard shortcuts

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