github.com/Rookout/GoSDK@v0.1.48/pkg/services/instrumentation/trigger_services.go (about)

     1  package instrumentation
     2  
     3  import (
     4  	"time"
     5  
     6  	"github.com/Rookout/GoSDK/pkg/types"
     7  	"github.com/go-errors/errors"
     8  )
     9  
    10  type TriggerServices struct {
    11  	instrumentationService *InstrumentationService
    12  }
    13  
    14  const breakpointMonitorInterval = 10 * time.Second
    15  
    16  func NewTriggerServices() (*TriggerServices, error) {
    17  	inst, err := NewInstrumentationService(breakpointMonitorInterval)
    18  	if err != nil {
    19  		return nil, err
    20  	}
    21  
    22  	return &TriggerServices{instrumentationService: inst}, nil
    23  }
    24  
    25  func (t TriggerServices) GetInstrumentation() *InstrumentationService {
    26  	if t.instrumentationService != nil {
    27  		return t.instrumentationService
    28  	}
    29  
    30  	
    31  	return nil
    32  }
    33  
    34  func (t TriggerServices) RemoveAug(augID types.AugID) error {
    35  	if t.instrumentationService != nil {
    36  		return t.instrumentationService.RemoveAug(augID)
    37  	}
    38  
    39  	return errors.Errorf("Couldn't remove aug (%s), instrumentationService is nil", augID)
    40  }
    41  
    42  func (t TriggerServices) ClearAugs() {
    43  	if t.instrumentationService != nil {
    44  		t.instrumentationService.ClearAugs()
    45  	}
    46  }
    47  
    48  func (t TriggerServices) Close() {
    49  	t.ClearAugs()
    50  
    51  	if t.instrumentationService != nil {
    52  		t.instrumentationService.Stop()
    53  	}
    54  }