Documentation
¶
Index ¶
- func InstrumentClient(client *http.Client) *http.Client
- func MatchForDownload(url *urls.URL, node *api.Node, globalDownloadRules *api.Downloads) (downloadResourceName string, isMatched bool)
- func MatchForLinkRewrite(absLink string, node *api.Node, ...) (version *string, destination *string, text *string, title *string, ...)
- func RegisterMetrics(reg prometheus.Registerer)
- func ResetMetrics()
- func SelectContent(contentBytes []byte, selectorExpression string) ([]byte, error)
- type DocumentController
- type DocumentWorkTask
- type DocumentWorker
- type Download
- type DownloadController
- type DownloadTask
- type GenericReader
- type NodeContentProcessor
- type Options
- type Reactor
- type Reader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InstrumentClient ¶
InstrumentClient instruments the client provided as argument to measure and report networking metrics
func MatchForDownload ¶ added in v0.5.0
func MatchForDownload(url *urls.URL, node *api.Node, globalDownloadRules *api.Downloads) (downloadResourceName string, isMatched bool)
MatchForDownload returns true if the provided URL is in the defined download scope for the node, and the resource name to use when serializing it.
func MatchForLinkRewrite ¶ added in v0.5.0
func MatchForLinkRewrite(absLink string, node *api.Node, globalRenameRules map[string]*api.LinkRewriteRule) (version *string, destination *string, text *string, title *string, isMatched bool)
MatchForLinkRewrite tries recursively from this node up to the hierarchy root link rewrite rules attached to nodes and finally defined globally that match this URL to apply them and rewrite the link or return it untouched.
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.
Types ¶
type DocumentController ¶ added in v0.2.0
type DocumentController interface {
jobs.Controller
// SetDownloadScope sets the scope for resources 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 enqueued documents. It amends 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 ¶
DocumentWorkTask implements jobs#Task
type DocumentWorker ¶
type DocumentWorker struct {
writers.Writer
Reader
processors.Processor
NodeContentProcessor NodeContentProcessor
}
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 wrapper around Controller#Enqueue
// for enqueuing download tasks. An error is returned if
// scheduling fails.
Schedule(ctx context.Context, link, resourceName string) error
}
DownloadController encapsulates activities for asynchronous 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 ¶
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
type NodeContentProcessor ¶
type NodeContentProcessor interface {
ReconcileLinks(ctx context.Context, node *api.Node, contentSourcePath string, documentBlob []byte) ([]byte, error)
GetDownloadController() DownloadController
}
NodeContentProcessor operates on documents content to reconcile links and schedule linked resources downloads
func NewNodeContentProcessor ¶
func NewNodeContentProcessor(resourcesRoot string, globalLinksConfig *api.Links, downloadJob DownloadController, failFast bool, markdownFmt bool, rewriteEmbedded bool, resourceHandlers resourcehandlers.Registry) NodeContentProcessor
NewNodeContentProcessor creates NodeContentProcessor objects
type Options ¶
type Options struct {
MaxWorkersCount int
MinWorkersCount int
FailFast bool
DestinationPath string
ResourcesPath string
ResourceDownloadWorkersCount int
MarkdownFmt bool
RewriteEmbedded bool
processors.Processor
ResourceDownloadWriter writers.Writer
Writer writers.Writer
ResourceHandlers []resourcehandlers.ResourceHandler
DryRunWriter writers.DryRunWriter
Resolve bool
GlobalLinksConfig *api.Links
}
Options encapsulates the parameters for creating new Reactor objects with NewReactor
type Reactor ¶
type Reactor struct {
FailFast bool
ResourceHandlers resourcehandlers.Registry
// localityDomain *localityDomain
DocController DocumentController
DownloadController DownloadController
DryRunWriter writers.DryRunWriter
Resolve bool
}
Reactor orchestrates the documentation build workflow
func (*Reactor) Build ¶
Build starts the build operation for a document structure root in a locality domain
func (*Reactor) ResolveManifest ¶ added in v0.5.0
ResolveManifest resolves the manifests into buildable model