github.com/Rookout/GoSDK@v0.1.48/pkg/processor/processor.go (about)

     1  package processor
     2  
     3  import (
     4  	"github.com/Rookout/GoSDK/pkg/processor/namespaces"
     5  	"github.com/Rookout/GoSDK/pkg/processor/operations"
     6  	"github.com/Rookout/GoSDK/pkg/rookoutErrors"
     7  	"github.com/Rookout/GoSDK/pkg/types"
     8  )
     9  
    10  type operationFactory interface {
    11  	GetOperation(configuration types.AugConfiguration) (operations.Operation, rookoutErrors.RookoutError)
    12  }
    13  
    14  type processor struct {
    15  	operationList []operations.Operation
    16  }
    17  
    18  func NewProcessor(configuration []types.AugConfiguration, factory operationFactory) (*processor, rookoutErrors.RookoutError) {
    19  	var operationList []operations.Operation
    20  	for _, rawOperation := range configuration {
    21  		operation, err := factory.GetOperation(rawOperation)
    22  		if err != nil {
    23  			return nil, err
    24  		}
    25  		operationList = append(operationList, operation)
    26  	}
    27  	return &processor{operationList: operationList}, nil
    28  }
    29  
    30  func (p *processor) Process(namespace namespaces.Namespace) {
    31  	for _, operation := range p.operationList {
    32  		operation.Execute(namespace)
    33  	}
    34  }