Skip to content
Merged
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
141 changes: 88 additions & 53 deletions connector/mock_connector/connector.go

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ require (
github.com/sirupsen/logrus v1.9.4
github.com/stretchr/testify v1.11.1
go.uber.org/goleak v1.3.0
go.uber.org/mock v0.6.0
golang.org/x/sys v0.43.0
golang.org/x/text v0.36.0
gopkg.in/yaml.v3 v3.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE=
go.uber.org/mock v0.6.0 h1:hyF9dfmbgIX5EfOdasqLsWD6xqpNZlXblLB/Dbnwv3Y=
go.uber.org/mock v0.6.0/go.mod h1:KiVJ4BqZJaMj4svdfmHM0AUx4NJYO8ZNpPnZn1Z+BBU=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
golang.org/x/exp v0.0.0-20260312153236-7ab1446f8b90 h1:jiDhWWeC7jfWqR9c/uplMOqJ0sbNlNWv0UkzE0vX1MA=
Expand Down
19 changes: 12 additions & 7 deletions internal/backend/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import (
"github.com/ProtonMail/gluon/imap"
"github.com/ProtonMail/gluon/internal/ids"
"github.com/ProtonMail/gluon/internal/state"
"github.com/ProtonMail/gluon/internal/unleash"
"github.com/ProtonMail/gluon/internal/unleash/featureflags"
"github.com/ProtonMail/gluon/internal/utils"
"github.com/ProtonMail/gluon/limits"
"github.com/ProtonMail/gluon/logging"
Expand Down Expand Up @@ -160,6 +162,8 @@ func newUser(

user.updateWG.Add(1)

featureFlagProvider := unleash.Get()

async.GoAnnotated(context.WithoutCancel(ctx), panicHandler, func(ctx context.Context) {
defer user.updateWG.Done()

Expand All @@ -173,13 +177,14 @@ func newUser(
}

if err := user.apply(ctx, update); err != nil {
// there's no events like this in sentry so far.
reporter.MessageWithContext(
ctx,
"Failed to apply connector update",
reporter.Context{"error": err, "update": update.String()},
)

if !featureFlagProvider.GetFlagValue(featureflags.ApplySentryEventsDisabled) {
reporter.MessageWithContextAndTags(
ctx,
"Failed to apply connector update",
reporter.Context{"error": err, "update": update.String()},
map[string]string{"source": "gluon"},
)
}
log.WithError(err).Errorf("Failed to apply update: %v", err)
}

Expand Down
1 change: 1 addition & 0 deletions internal/unleash/featureflags/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ const (
ConnectionLimiterDefaultLimitsDisabled = "InboxBridgeGluonConnectionLimiterDefaultLimitsDisabled"
ConnectionCounterConnectionsLimitDisabled = "InboxBridgeGluonRollingCounterConnectionLimitDisabled"
MaximumMIMEStructureDepthDisabled = "InboxBridgeGluonMaximumMimeStructureDepthLimitDisabled"
ApplySentryEventsDisabled = "InboxDesktopGluonApplySentryEventsDisabled"
)
2 changes: 1 addition & 1 deletion internal/unleash/singleton.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

var (
instance FeatureFlagValueProvider
instance FeatureFlagValueProvider = &NullFeatureFlagProvider{}
syncOnce sync.Once
)

Expand Down
38 changes: 29 additions & 9 deletions reporter/mock_reporter/mock_reporter.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions reporter/null_reporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ func (*NullReporter) ReportMessage(string) error {
return nil
}

func (*NullReporter) ReportMessageWithContextAndTags(string, Context, Tags) error {
return nil
}

func (*NullReporter) ReportMessageWithContext(string, Context) error {
return nil
}
Expand Down
2 changes: 2 additions & 0 deletions reporter/reporter.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package reporter

type Context = map[string]any
type Tags = map[string]string

// Reporter represents an external reporting tool which can be hooked into gluon to report key information and/or
// unexpected behaviors.
Expand All @@ -9,5 +10,6 @@ type Reporter interface {
ReportMessage(string) error
ReportMessageWithContext(string, Context) error
ReportWarningWithContext(string, Context) error
ReportMessageWithContextAndTags(string, Context, Tags) error
ReportExceptionWithContext(any, Context) error
}
11 changes: 11 additions & 0 deletions reporter/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ func MessageWithContext(ctx context.Context, message string, context Context) {
}
}

func MessageWithContextAndTags(ctx context.Context, message string, context Context, tags Tags) {
reporter, ok := GetReporterFromContext(ctx)
if !ok {
return
}

if err := reporter.ReportMessageWithContextAndTags(message, context, tags); err != nil {
logrus.WithError(err).Error("Failed to report message")
}
}

func ExceptionWithContext(ctx context.Context, message string, context Context) {
reporter, ok := GetReporterFromContext(ctx)
if !ok {
Expand Down
34 changes: 20 additions & 14 deletions store/mock_store/store.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tests/non_utf8_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import (

"github.com/ProtonMail/gluon/reporter/mock_reporter"
"github.com/emersion/go-imap/client"
"github.com/golang/mock/gomock"
"github.com/stretchr/testify/require"
gomock "go.uber.org/mock/gomock"
)

func TestSSLConnectionOverStartTLS(t *testing.T) {
Expand Down
4 changes: 4 additions & 0 deletions tests/reporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ func (r *testReporter) ReportMessageWithContext(val string, ctx reporter.Context
return nil
}

func (r *testReporter) ReportMessageWithContextAndTags(val string, ctx reporter.Context, tags map[string]string) error {
return r.ReportMessageWithContext(val, ctx)
}

func (r *testReporter) ReportWarningWithContext(val string, ctx reporter.Context) error {
r.lock.Lock()
defer r.lock.Unlock()
Expand Down
Loading