Skip to content

Commit

Permalink
refactor: Update alert system with rate limiting, options, and gorout…
Browse files Browse the repository at this point in the history
…ine sender

- Refactor and rename `alert pusher hook` to `alertMutation`
- Introduce `RateLimiter` interface for rate limiting alert sending
- Implement extensive configuration options for `Alert` hook
- Enhance `Alert` struct functionality
  • Loading branch information
Laisky committed Jul 17, 2024
1 parent 34dbeb2 commit a6d7f90
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions gorm/fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func (j JSON) Value() (driver.Value, error) {
if j.IsNull() {
return nil, nil
}

return string(j), nil
}

Expand Down
7 changes: 4 additions & 3 deletions log/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func TestAlertHook(t *testing.T) {
context.Background(),
"https://gq.laisky.com/query/",
WithAlertType("hello"),
WithAlertToken("rwkpVuAgaBZQBASKndHK"),
WithAlertToken("YOUR_ALERT_TOKEN"),
)
require.NoError(t, err)

Expand All @@ -31,14 +31,15 @@ func TestAlertHook(t *testing.T) {
logger.Error("Error", zap.String("yo", "hello"), zap.Bool("bool", true), zap.Error(errors.Errorf("xxx")))
// t.Error()

time.Sleep(5 * time.Second)
// time.Sleep(1 * time.Second)
}

func ExampleAlert() {
pusher, err := NewAlert(
context.Background(),
"https://gq.laisky.com/query/",
WithAlertType("hello"),
WithAlertToken("rwkpVuAgaBZQBASKndHK"),
WithAlertToken("YOUR_ALERT_TOKEN"),
WithAlertHookLevel(zap.InfoLevel),
)
if err != nil {
Expand Down

1 comment on commit a6d7f90

@eliasdiek
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Laisky hey ,I'm looking for someone with your stack to work on our platform ,either as a freelancer or in a full time role . are you up for it ? contact me on telegram @eliasdiek or via email at [email protected]

Please sign in to comment.