indexer

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Indexer

type Indexer struct {
	// AlgoliaClient is the Algolia client.
	AlgoliaClient *algolia.Client

	// BaseURL is the base URL for the application.
	BaseURL string

	// Database is the database connection.
	Database *gorm.DB

	// DocumentsFolderID is the Google Drive ID of the folder containing published
	// documents to index.
	DocumentsFolderID string

	// DocumentTypes are a slice of document types from the application config.
	DocumentTypes []*config.DocumentType

	// DraftsFolderID is the Google Drive ID of the folder containing draft
	// documents to index.
	DraftsFolderID string

	// GoogleWorkspaceService is the Google Workspace service.
	GoogleWorkspaceService *gw.Service

	// Logger is the logger to use.
	Logger hclog.Logger

	// MaxParallelDocuments is the maximum number of documents that will be
	// simultaneously indexed.
	MaxParallelDocuments int

	// UpdateDocumentHeaders updates published document headers, if true.
	UpdateDocumentHeaders bool

	// UpdateDraftHeaders updates draft document headers, if true.
	UpdateDraftHeaders bool

	// UseDatabaseForDocumentData will use the database instead of Algolia as the
	// source of truth for document data, if true.
	UseDatabaseForDocumentData bool
}

Indexer contains the indexer configuration.

func NewIndexer

func NewIndexer(opts ...IndexerOption) (*Indexer, error)

NewIndexer creates a new indexer.

func (*Indexer) Run

func (idx *Indexer) Run() error

Run runs the indexer. TODO: improve error handling.

type IndexerOption

type IndexerOption func(*Indexer)

func WithAlgoliaClient

func WithAlgoliaClient(a *algolia.Client) IndexerOption

WithAlgoliaClient sets the Algolia client.

func WithBaseURL

func WithBaseURL(b string) IndexerOption

WithBaseURL sets the base URL.

func WithDatabase

func WithDatabase(db *gorm.DB) IndexerOption

WithDatabase sets the database.

func WithDocumentTypes added in v0.4.0

func WithDocumentTypes(dts []*config.DocumentType) IndexerOption

WithDocumentTypes sets the document types.

func WithDocumentsFolderID

func WithDocumentsFolderID(d string) IndexerOption

WithDocumentsFolderID sets the documents folder ID.

func WithDraftsFolderID

func WithDraftsFolderID(d string) IndexerOption

WithDraftsFolderID sets the drafts folder ID.

func WithGoogleWorkspaceService

func WithGoogleWorkspaceService(g *gw.Service) IndexerOption

WithGoogleWorkspaceService sets the Google Workspace service.

func WithLogger

func WithLogger(l hclog.Logger) IndexerOption

WithLogger sets the logger.

func WithMaxParallelDocuments

func WithMaxParallelDocuments(m int) IndexerOption

WithMaxParallelDocuments sets the number of documents (per folder) to index in parallel.

func WithUpdateDocumentHeaders

func WithUpdateDocumentHeaders(u bool) IndexerOption

WithUpdateDocumentHeaders sets the boolean to update draft document headers.

func WithUpdateDraftHeaders

func WithUpdateDraftHeaders(u bool) IndexerOption

WithUpdateDraftHeaders sets the boolean to update draft document headers.

func WithUseDatabaseForDocumentData added in v0.4.0

func WithUseDatabaseForDocumentData(u bool) IndexerOption

WithUseDatabaseForDocumentData sets the boolean to use the database for document data.

Jump to

Keyboard shortcuts

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