reactor

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2020 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InstrumentClient

func InstrumentClient(client *http.Client) *http.Client

InstrumentClient instruments the client provided as argument to measure and report networking metrics

func RegisterMetrics

func RegisterMetrics(reg prometheus.Registerer)

RegisterMetrics registers the http client metrics. The second parameter `reg` can be used to provide a custom registry, e.g. for tests.

func ResetMetrics

func ResetMetrics()

ResetMetrics resets the metrics

func SelectContent

func SelectContent(contentBytes []byte, selectorExpression string) ([]byte, error)

SelectContent TODO: Not implemented

Types

type DocumentController added in v0.2.0

type DocumentController interface {
	jobs.Controller
	// SetDownloadScope sets the scope for respurces considered "local"
	// and therefore downloaded and relatively linked
	SetDownloadScope(scope *localityDomain)
	// GetDownloadController is accessor for the DownloadController
	// working with this DocumentController
	GetDownloadController() DownloadController
}

DocumentController is the functional interface for a controller handling tasks for processing enqued documents. It ammends the jobs.Controller interface with specific methods.

func NewDocumentController added in v0.2.0

func NewDocumentController(worker *DocumentWorker, workersCount int, failfast bool) DocumentController

NewDocumentController creates a controller for processing documents.

type DocumentWorkTask

type DocumentWorkTask struct {
	Node *api.Node
}

DocumentWorkTask implements jobs#Task

type DocumentWorker

type DocumentWorker struct {
	writers.Writer
	Reader
	processors.Processor
	NodeContentProcessor *NodeContentProcessor
	// contains filtered or unexported fields
}

DocumentWorker implements jobs#Worker

func (*DocumentWorker) Work

func (w *DocumentWorker) Work(ctx context.Context, task interface{}, wq jobs.WorkQueue) *jobs.WorkerError

Work implements Worker#Work function

type Download added in v0.2.0

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

Download represents a resource that can be downloaded

type DownloadController added in v0.2.0

type DownloadController interface {
	jobs.Controller
	// Schedule is a typesafe wrtapper around Controller#Enqueue
	// for enquing download tasks
	Schedule(ctx context.Context, link, resourceName string)
}

DownloadController encapsulates activities for asyncronous and parallel scheduling and download of resources

func NewDownloadController added in v0.2.0

func NewDownloadController(reader Reader, writer writers.Writer, workersCount int, failFast bool, rhs resourcehandlers.Registry) DownloadController

NewDownloadController creates DownloadController object

type DownloadTask

type DownloadTask struct {
	Source string
	Target string
}

DownloadTask holds information for source and target of linked document resources

type GenericReader

type GenericReader struct {
	ResourceHandlers resourcehandlers.Registry
}

GenericReader is generic implementation for Reader interface

func (*GenericReader) Read

func (g *GenericReader) Read(ctx context.Context, source string) ([]byte, error)

Read reads from the resource at the source URL delegating the the actual operation to a suitable resource hadler

type NodeContentProcessor

type NodeContentProcessor struct {
	DownloadController DownloadController

	ResourceHandlers resourcehandlers.Registry
	// contains filtered or unexported fields
}

NodeContentProcessor operates on documents content to reconcile links and schedule linked resources downloads

func NewNodeContentProcessor

func NewNodeContentProcessor(resourcesRoot string, ld *localityDomain, downloadJob DownloadController, failFast bool, markdownFmt bool, resourceHandlers resourcehandlers.Registry) *NodeContentProcessor

NewNodeContentProcessor creates NodeContentProcessor objects

func (c *NodeContentProcessor) ReconcileLinks(ctx context.Context, node *api.Node, contentSourcePath string, documentBlob []byte) ([]byte, error)

ReconcileLinks analyzes a document referenced by a node's contentSourcePath and processes its links to other resources to resolve their inconsistencies. The processing might involve rewriting links to relative and having new destinations, or rewriting them to absolute, as well as downloading some of the linked resources. The function returns the processed document or error.

type Options

type Options struct {
	MaxWorkersCount              int
	MinWorkersCount              int
	FailFast                     bool
	DestinationPath              string
	ResourcesPath                string
	ResourceDownloadWorkersCount int
	MarkdownFmt                  bool
	processors.Processor
	ResourceDownloadWriter writers.Writer
	Writer                 writers.Writer
	ResourceHandlers       []resourcehandlers.ResourceHandler
	DryRunWriter           writers.DryRunWriter
	Resolve                bool
}

Options encapsulates the parameters for creating new Reactor objects wiht NewReactor

type Reactor

type Reactor struct {
	FailFast         bool
	ResourceHandlers resourcehandlers.Registry

	DocController      DocumentController
	DownloadController DownloadController
	DryRunWriter       writers.DryRunWriter
	Resolve            bool
	// contains filtered or unexported fields
}

Reactor orchestrates the documentation build workflow

func NewReactor

func NewReactor(o *Options) *Reactor

NewReactor creates a Reactor from Options

func (*Reactor) Build

func (r *Reactor) Build(ctx context.Context, documentationRoot *api.Node, localityDomain *localityDomain) error

Build starts the build operation for a document structure root in a locality domain

func (*Reactor) ResolveStructure added in v0.3.0

func (r *Reactor) ResolveStructure(ctx context.Context, node *api.Node) error

ResolveStructure builds the subnodes hierarchy of a node based on the natural nodes hierarchy and on rules such as those in NodeSelector. The node hierarchy is resolved by an appropriate handler selected based on the NodeSelector path URI The resulting model is the actual flight plan for replicating resources.

func (*Reactor) Run

func (r *Reactor) Run(ctx context.Context, docStruct *api.Documentation, dryRun bool) error

Run starts build operation on docStruct

type Reader

type Reader interface {
	Read(ctx context.Context, source string) ([]byte, error)
}

Reader reads the bytes data from a given source URI

Jump to

Keyboard shortcuts

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