textclassifier

package
v1.0.0-alpha.3 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2021 License: BSD-2-Clause Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultShouldScheduleNextJobs

func DefaultShouldScheduleNextJobs(*gorm.DB, *models.WebArticle) (bool, error)

DefaultShouldScheduleNextJobs is the default implementation of TextClassifier.ShouldScheduleNextJobs.

It always returns true and no error.

Types

type ShouldScheduleNextJobsFn

type ShouldScheduleNextJobsFn func(tx *gorm.DB, wa *models.WebArticle) (bool, error)

ShouldScheduleNextJobsFn is a function which returns a boolean flag that indicates whether a TextClassifier job should proceed scheduling the next configured jobs upon successful completion.

Arguments:

	tx: the Gorm transaction instance created for the current job.
	    It can be used for getting data from the DB if needed; otherwise
	    it can be ignored.
	wa: the WebArticle that has been classified. wa.TextClasses contains the
     classification's results (depending on the implementation, it might
     be empty). This value MUST NOT be modified.

Returned values:

  • If true is returned with no error, the configured config.TextClassifier.ProcessedWebArticleJobs will be scheduled.
  • If false is returned with no error, no new jobs will be scheduled.
  • If the returned error is not nil, the boolean value is ignored and the whole job will be aborted.

type TextClassifier

type TextClassifier struct {
	basemodelworker.Worker
	// A custom function can be assigned for deciding whether to schedule or
	// not the configured next jobs upon completion
	//
	// The default value is DefaultShouldScheduleNextJobs.
	ShouldScheduleNextJobs ShouldScheduleNextJobsFn
	// contains filtered or unexported fields
}

TextClassifier implements a Faktory worker for classifying existing WebArticles with a generic text classifier.

func New

func New(
	conf config.TextClassifier,
	db *gorm.DB,
	classifierConn *grpc.ClientConn,
	fk *faktory_worker.Manager,
) *TextClassifier

New creates a new TextClassifier.

Jump to

Keyboard shortcuts

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