github.com/Rookout/GoSDK@v0.1.48/pkg/augs/locations/location_file_line.go (about) 1 package locations 2 3 import ( 4 "github.com/Rookout/GoSDK/pkg/augs" 5 "github.com/Rookout/GoSDK/pkg/com_ws" 6 "github.com/Rookout/GoSDK/pkg/logger" 7 "github.com/Rookout/GoSDK/pkg/rookoutErrors" 8 "github.com/Rookout/GoSDK/pkg/types" 9 ) 10 11 type LocationFileLine struct { 12 filename string 13 lineno int 14 output com_ws.Output 15 aug augs.Aug 16 17 status string 18 } 19 20 func (l *LocationFileLine) sendRuleStatus(status string, err rookoutErrors.RookoutError) error { 21 if l.status == status { 22 return nil 23 } 24 25 logger.Logger().WithError(err).Infof("Updating rule status for: %s to %s\n", l.GetAugID(), status) 26 27 l.status = status 28 return l.output.SendRuleStatus(l.GetAugID(), status, err) 29 } 30 31 func (l *LocationFileLine) SetPending() error { 32 return l.sendRuleStatus("Pending", nil) 33 } 34 35 func (l *LocationFileLine) SetActive() error { 36 return l.sendRuleStatus("Active", nil) 37 } 38 39 func (l *LocationFileLine) SetRemoved() error { 40 return l.sendRuleStatus("Deleted", nil) 41 } 42 43 func (l *LocationFileLine) SetError(err rookoutErrors.RookoutError) error { 44 return l.sendRuleStatus("Error", err) 45 } 46 47 func NewLocationFileLine(arguments types.AugConfiguration, output com_ws.Output, aug augs.Aug) (Location, rookoutErrors.RookoutError) { 48 var location LocationFileLine 49 50 location.filename = arguments["filename"].(string) 51 location.lineno = int(arguments["lineno"].(float64)) 52 location.aug = aug 53 location.output = output 54 55 return &location, nil 56 } 57 58 func (l *LocationFileLine) GetLineno() int { 59 return l.lineno 60 } 61 62 func (l *LocationFileLine) GetFileName() string { 63 return l.filename 64 } 65 66 func (l *LocationFileLine) GetAug() augs.Aug { 67 return l.aug 68 } 69 70 func (l *LocationFileLine) GetAugID() types.AugID { 71 return l.aug.GetAugID() 72 }