gitlab.com/SkynetLabs/skyd@v1.6.9/skymodules/alert.go (about)

     1  package skymodules
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"gitlab.com/SkynetLabs/skyd/build"
     7  	"go.sia.tech/siad/modules"
     8  )
     9  
    10  // AlertIDWorkerAccountBalanceDrift is a function that returns the ID of the
    11  // alert that is registered when a worker's account balance has drifted from
    12  // what the host claims to be in the renter's ephemeral account, more than the
    13  // allowed threshold
    14  //
    15  // NOTE: the ID is unique to a worker as we supply a host's pubkey
    16  func AlertIDWorkerAccountBalanceDrift(workerHostKey string) modules.AlertID {
    17  	return modules.AlertID(fmt.Sprintf("balance-drift-%v", workerHostKey))
    18  }
    19  
    20  // AlertIDWorkerAccountOutOfFunds is a function that returns the ID of the alert
    21  // that is registered when a worker's encountering insufficient balance errors
    22  // from the host, while according to its own accounting the balance has not
    23  // dropped below the refill threshold
    24  //
    25  // NOTE: the ID is unique to a worker as we supply a host's pubkey
    26  func AlertIDWorkerAccountOutOfFunds(workerHostKey string) modules.AlertID {
    27  	return modules.AlertID(fmt.Sprintf("out-of-funds-%v", workerHostKey))
    28  }
    29  
    30  // NewAlerter creates a new alerter for a given module. When building for
    31  // testing this will also register some dummy alerts.
    32  func NewAlerter(module string) *modules.GenericAlerter {
    33  	a := modules.NewAlerter(module)
    34  
    35  	// In testing we register some alerts.
    36  	if build.Release != "testing" {
    37  		return a
    38  	}
    39  	a.RegisterAlert(modules.AlertID(module+" - Dummy0"), "msg0", "cause0", modules.SeverityInfo)
    40  	a.RegisterAlert(modules.AlertID(module+" - Dummy1"), "msg1", "cause1", modules.SeverityWarning)
    41  	a.RegisterAlert(modules.AlertID(module+" - Dummy2"), "msg2", "cause2", modules.SeverityError)
    42  	a.RegisterAlert(modules.AlertID(module+" - Dummy3"), "msg3", "cause3", modules.SeverityCritical)
    43  	return a
    44  }