Skip to content

Commit

Permalink
Extend support for ErrorReporting.
Browse files Browse the repository at this point in the history
Adds Publisher which directly supports GCP ErrorReporting.
  • Loading branch information
AndreasBergmeier6176 committed Jan 16, 2024
1 parent 169fe0b commit 4846ee8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## v0.0.44 ErrorReporting
- Add `errorreports.Error`

Special error interface so that it is possible to generate a GCP ErrorReport directly from `error`.
- Add `publisher.Publisher`

Use `Publisher` for rich publish integration. Resulting error can directly be used for GCP ErrorReporting.

## v0.0.39 More options for envflags
- Add function `envflags.GetBoolDefault`

Expand Down
14 changes: 14 additions & 0 deletions pkg/gcp/errorreports/error.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package errorreports

import (
"cloud.google.com/go/errorreporting"
)

// Error can be used to build a `errorreporting.Entry`.
type Error interface {
error

// ReportingEntry uses the saved error information to build
// an `errorreporting.Entry`.
ReportingEntry() *errorreporting.Entry
}
22 changes: 22 additions & 0 deletions pkg/publisher/publisher.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package publisher

import (
"context"

"github.com/otto-de/sherlock-microservice/pkg/gcp/errorreports"
)

type Option struct {
orderingKey string
}

func WithOrderingKey(orderingKey string) Option {
return Option{
orderingKey: orderingKey,
}
}

type Publisher[EV any] interface {
// Publish publishes an Event to Target.
Publish(ctx context.Context, event *EV, opts ...Option) errorreports.Error
}

0 comments on commit 4846ee8

Please sign in to comment.