Documentation
¶
Overview ¶
Package service provides the core parsing service for L8Parser. It contains the Parser singleton that orchestrates rule execution for transforming collected data into structured inventory objects, and the ParsingService that integrates with the L8 ecosystem for processing collection jobs.
Index ¶
- Constants
- Variables
- func Activate(linksID string, serviceItem interface{}, persist bool, vnic ifs.IVNic, ...)
- func LoadJob(pollarisName, jobName, deviceId, hostId string) (*l8tpollaris.CJob, error)
- func RegisterRule(rule rules.ParsingRule)
- type ParsingService
- func (this *ParsingService) Activate(sla *ifs.ServiceLevelAgreement, vnic ifs.IVNic) error
- func (this *ParsingService) DeActivate() error
- func (this *ParsingService) Delete(pb ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) Failed(pb ifs.IElements, vnic ifs.IVNic, msg *ifs.Message) ifs.IElements
- func (this *ParsingService) Get(pb ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) GetCopy(pb ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) HandleDelete(job *l8tpollaris.CJob)
- func (this *ParsingService) JobComplete(job *l8tpollaris.CJob, resources ifs.IResources)
- func (this *ParsingService) Patch(pb ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) Post(pbs ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) Put(pb ifs.IElements, vnic ifs.IVNic) ifs.IElements
- func (this *ParsingService) TransactionConfig() ifs.ITransactionConfig
- func (this *ParsingService) WebService() ifs.IWebService
Constants ¶
const (
JobFileLocation = "./jobsPersistency/"
)
JobFileLocation is the directory path where job results are persisted when persistence is enabled.
Variables ¶
var Parser = newParser()
Parser is the singleton instance of the parser engine, initialized with all available rules.
Functions ¶
func Activate ¶
func Activate(linksID string, serviceItem interface{}, persist bool, vnic ifs.IVNic, primaryKeys ...string)
Activate initializes and registers the parsing service with the L8 ecosystem. Parameters: linksID (the links identifier), serviceItem (prototype instance for parsing), persist (whether to save jobs to disk), vnic (virtual NIC for communication), primaryKeys (keys for the service item).
func LoadJob ¶
func LoadJob(pollarisName, jobName, deviceId, hostId string) (*l8tpollaris.CJob, error)
LoadJob loads a persisted job from disk for replay or debugging purposes. Parameters: pollarisName, jobName, deviceId, hostId to identify the job file.
func RegisterRule ¶
func RegisterRule(rule rules.ParsingRule)
RegisterRule adds an external parsing rule to the parser singleton. This allows projects to register project-specific rules at runtime without creating circular import dependencies.
Types ¶
type ParsingService ¶
type ParsingService struct {
// contains filtered or unexported fields
}
ParsingService is the main service that processes collection job results. It implements the L8 service interface and handles parsing of collected data into structured inventory objects. It supports job persistence for debugging and replay purposes.
func (*ParsingService) Activate ¶
func (this *ParsingService) Activate(sla *ifs.ServiceLevelAgreement, vnic ifs.IVNic) error
Activate is called when the service is activated. It initializes the service state, registers required types with the registry, and sets up job persistence if enabled.
func (*ParsingService) DeActivate ¶
func (this *ParsingService) DeActivate() error
DeActivate is called when the service is deactivated. It cleans up service resources.
func (*ParsingService) HandleDelete ¶
func (this *ParsingService) HandleDelete(job *l8tpollaris.CJob)
HandleDelete processes a delete CJob from the collector. It decodes the resource keys from CJob.Result (a serialized CMap), constructs a minimal proto instance with primary key fields set, and forwards it to the inventory cache with ifs.DELETE action.
func (*ParsingService) JobComplete ¶
func (this *ParsingService) JobComplete(job *l8tpollaris.CJob, resources ifs.IResources)
JobComplete is called when a collection job completes. It parses the job results using the Parser, creates an element instance, and sends the parsed data to the inventory cache service via PATCH operation. For polls using CTableToInstances, it sends each created instance individually.
func (*ParsingService) Post ¶
Post handles incoming collection job results. It optionally persists jobs to disk and triggers the JobComplete handler for each received job.
func (*ParsingService) TransactionConfig ¶
func (this *ParsingService) TransactionConfig() ifs.ITransactionConfig
func (*ParsingService) WebService ¶
func (this *ParsingService) WebService() ifs.IWebService