Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ type Config struct {
TestHttpClient *http.Client `json:"-"`
}

// Parse parsees configs from json file
// Parse parses configs from json file
func ParseConfig(jsonConfig string, appConfig *Config) error {
file, err := os.Open(jsonConfig)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions aggregationManager.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (a *AggregationManager) RegisterMetrics(reg gometrics.Registry) {
reg.Register("aggregationManager.internal.plans_under_aggregation_total", gaugeAggregatedPlansTotal)
}

// NewAggregationManager create new AggregationManager
// NewAggregationManager creates a new AggregationManager
func NewAggregationManager(irisClient *IrisClient, config *Config, logger *Logger, quit chan int, wg *sync.WaitGroup, metricsRegistry *gometrics.Registry) *AggregationManager {

aggregationManager := AggregationManager{
Expand Down Expand Up @@ -127,7 +127,7 @@ func (a *AggregationManager) resetAggregation() {
}
} else {
if planAgg.incidentCount > 0 {
// if the collectionwindow has elapsed without triggering aggregation reset it and the count
// if the collection window has elapsed without triggering aggregation reset it and the count
if time.Since(planAgg.collectionTime) > planAgg.collectionWindow {
planAgg.incidentCount = 0
a.planAggregationMap[planAgg.planName] = planAgg
Expand All @@ -139,7 +139,7 @@ func (a *AggregationManager) resetAggregation() {
gaugeAggregatedPlansTotal.Update(aggregatedPlansTotal)
}

// check if the aggregations settings have changed for each plan and update them if necessary
// check if the aggregation settings have changed for each plan and update them if necessary
func (a *AggregationManager) updateSettings(aggSettingResp []PlanAggregationResp) {
a.aggregationMutex.Lock()
defer a.aggregationMutex.Unlock()
Expand Down
6 changes: 3 additions & 3 deletions dbClient.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ func (d *DbClient) writeStatus(msgID string, statusStr string, vendorMessageIden
return err
}
if len(storedRecord.MessageID) > 0 {
// a status already exists update it
// a status already exists, update it
err = d.db.UpdateMessageStatus(newStatusRecord)
if err != nil {
d.logger.Errorf("Failed to update message status with error: %w", err)
Expand Down Expand Up @@ -198,10 +198,10 @@ func (d *DbClient) getChangelogs(msgID string) ([]MessageChangelogRecord, error)

// TODO implement the rest of the mysql functions alongside the apis to fetch messages and insert callbacks

// NewDbClient create new DbClient instance
// NewDbClient creates a new DbClient instance
func NewDbClient(config *Config, logger *Logger, metricsRegistry *gometrics.Registry) *DbClient {

// interface allows the underlying db to be easiuly replaced with something else if needed
// interface allows the underlying db to be easily replaced with something else if needed
var db DBInterface
db = NewSQLDB(config, logger.Clone("mysql"), metricsRegistry)

Expand Down
8 changes: 4 additions & 4 deletions hmacAuth.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ type AuthChecker struct {
readyStatus bool
}

// AuthHeader compute hmac authorization header and hmac hash
// AuthHeader computes the HMAC authorization header and hmac hash
func AuthHeader(method, path string, body []byte, application string, key []byte) (string, string, error) {
payload := strconv.AppendInt(make([]byte, 0), time.Now().UTC().Unix()/30, 10)
payload = append(payload, ' ')
Expand Down Expand Up @@ -62,7 +62,7 @@ func (a *AuthChecker) CheckStatus() bool {
return a.readyStatus
}

// CheckAuth evaluates a requests Authorization header
// CheckAuth evaluates a request's Authorization header
func (a *AuthChecker) CheckAuth(request *http.Request) (bool, error) {

// if auth debug mode is enabled skip checking authentication
Expand Down Expand Up @@ -129,7 +129,7 @@ func (a *AuthChecker) CheckAuth(request *http.Request) (bool, error) {
return true, nil
}

// NewAuthChecker create new AuthChecker instance
// NewAuthChecker creates a new AuthChecker instance
func NewAuthChecker(irisClient *IrisClient, config *Config, logger *Logger, quit chan int, wg *sync.WaitGroup, metricsRegistry *gometrics.Registry) *AuthChecker {

authChecker := AuthChecker{
Expand All @@ -149,7 +149,7 @@ func NewAuthChecker(irisClient *IrisClient, config *Config, logger *Logger, quit
return &authChecker
}

// Run update application auth info every 60 seconds
// Run updates the application auth info every 60 seconds
func (a *AuthChecker) Run() {
// close wg to signal main process we have gracefully terminated
defer a.mainWg.Done()
Expand Down
10 changes: 5 additions & 5 deletions logger.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Package logger provides Logger which the rest of the project
// should be using for all logging purposes. This logger essentially
// embed zap's SugaredLogger for structured logging (use methods that
// ends in `w', e.g. Infow, Debugw). For documentation refer to
// end in `w', e.g. Infow, Debugw). For documentation refer to
// https://pkg.go.dev/go.uber.org/zap?tab=doc#SugaredLogger. User
// should setup log rotation when initializing this logger.
// should set up log rotation when initializing this logger.
//
// Uses zap and lumberjack.
package main
Expand All @@ -21,7 +21,7 @@ import (
const (
defaultLogMaxBackups = 15 // daily log files older than this will be automatically deleted
defaultLogCompress = true // compress log files
defaultLogLocal = true // should log file *name* timestamps be server time? If false, will default to URC
defaultLogLocal = true // should log file *name* timestamps be server time? If false, will default to UTC
defaultLogTSFormat = "2006-01-02 15:04:05"
)

Expand Down Expand Up @@ -104,7 +104,7 @@ func NewLogger(name string, logPath string, debug bool) *Logger {
}
}

// NewChild creates a child logger that refer to the same logger as
// NewChild creates a child logger that refers to the same logger as
// the parent. Also extend its name and add additional fields.
func (l *Logger) NewChild(name string, fields ...interface{}) *Logger {
return &Logger{
Expand All @@ -126,7 +126,7 @@ func (l *Logger) AddContexts(fields ...interface{}) *Logger {
}
}

// Clone creates an independent logger that get initialized with the
// Clone creates an independent logger that gets initialized with the
// same logging level as the source logger.
func (l *Logger) Clone(name string, fields ...interface{}) *Logger {
lvl := zap.NewAtomicLevelAt(l.zapAtomicLevel.Level())
Expand Down
2 changes: 1 addition & 1 deletion metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ func (c *MetricsCollector) CollectRuntimeMemStats() {

// Emit collected metrics
func (c *MetricsCollector) EmitMetrics() {
c.logger.Infof("Dummy emitt metrics...")
c.logger.Infof("Dummy emit metrics...")

}