Skip to content

Commit

Permalink
changes based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gouthamp-stellar committed Sep 11, 2024
1 parent d9a3448 commit 73a2f0a
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 18 deletions.
4 changes: 2 additions & 2 deletions cmd/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ func (c *ingestCmd) Command() *cobra.Command {
}
appTracker, err := sentry.NewSentryTracker(sentryDSN, stellarEnvironment, 5)
if err != nil {
log.Fatalf("Error initializing App Tracker: %s", err.Error())
return fmt.Errorf("initializing app tracker: %w", err)
}
cfg.AppTracker = *appTracker
cfg.AppTracker = appTracker
return nil
},
RunE: func(_ *cobra.Command, _ []string) error {
Expand Down
2 changes: 1 addition & 1 deletion cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (c *serveCmd) Command() *cobra.Command {
if err != nil {
return fmt.Errorf("initializing App Tracker: %w", err)
}
cfg.AppTracker = *appTracker
cfg.AppTracker = appTracker

channelAccountSignatureClient, err := signing.NewChannelAccountDBSignatureClient(dbConnectionPool, cfg.NetworkPassphrase, &signingutils.DefaultPrivateKeyEncrypter{}, cfg.EncryptionPassphrase)
if err != nil {
Expand Down
6 changes: 2 additions & 4 deletions internal/apptracker/sentry/sentry_tracker.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ var (
RecoverFunc = sentry.Recover
)

type SentryTracker struct {
FlushFreq int64
}
type SentryTracker struct{}

func (s *SentryTracker) CaptureMessage(message string) {
captureMessageFunc(message)
Expand All @@ -37,6 +35,6 @@ func NewSentryTracker(dsn string, env string, flushFreq int) (*SentryTracker, er
}
defer FlushFunc(time.Second * time.Duration(flushFreq))
defer RecoverFunc()
return &SentryTracker{FlushFreq: int64(flushFreq)}, nil
return &SentryTracker{}, nil

}
1 change: 0 additions & 1 deletion internal/apptracker/sentry/sentry_tracker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ func TestNewSentryTracker_Success(t *testing.T) {

assert.NoError(t, err)
assert.NotNil(t, tracker)
assert.Equal(t, int64(5), tracker.FlushFreq)

mockSentry.AssertCalled(t, "Init", mock.Anything)
mockSentry.AssertCalled(t, "Flush", time.Second*5)
Expand Down
6 changes: 3 additions & 3 deletions internal/ingest/ingest.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import (
"github.com/stellar/go/ingest/ledgerbackend"
"github.com/stellar/go/network"
"github.com/stellar/go/support/log"
"github.com/stellar/wallet-backend/internal/apptracker/sentry"
"github.com/stellar/wallet-backend/internal/apptracker"
"github.com/stellar/wallet-backend/internal/data"
"github.com/stellar/wallet-backend/internal/db"
"github.com/stellar/wallet-backend/internal/services"
Expand All @@ -26,7 +26,7 @@ type Configs struct {
StartLedger int
EndLedger int
LogLevel logrus.Level
AppTracker sentry.SentryTracker
AppTracker apptracker.AppTracker
}

func Ingest(cfg Configs) error {
Expand Down Expand Up @@ -70,7 +70,7 @@ func setupDeps(cfg Configs) (*services.IngestManager, error) {
LedgerCursorName: cfg.LedgerCursorName,
LedgerBackend: ledgerBackend,
PaymentModel: models.Payments,
AppTracker: &cfg.AppTracker,
AppTracker: cfg.AppTracker,
}, nil
}

Expand Down
8 changes: 4 additions & 4 deletions internal/serve/httphandler/account_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ func (h AccountHandler) RegisterAccount(w http.ResponseWriter, r *http.Request)
ctx := r.Context()

var reqParams AccountRegistrationRequest
httpErr := DecodePathAndValidate(ctx, r, &reqParams)
httpErr := DecodePathAndValidate(ctx, r, &reqParams, h.AppTracker)
if httpErr != nil {
httpErr.Render(w)
return
}

err := h.AccountService.RegisterAccount(ctx, reqParams.Address)
if err != nil {
httperror.InternalServerError(ctx, "", err, nil).Render(w)
httperror.InternalServerError(ctx, "", err, nil, h.AppTracker).Render(w)
return
}

Expand All @@ -46,15 +46,15 @@ func (h AccountHandler) DeregisterAccount(w http.ResponseWriter, r *http.Request
ctx := r.Context()

var reqParams AccountRegistrationRequest
httpErr := DecodePathAndValidate(ctx, r, &reqParams)
httpErr := DecodePathAndValidate(ctx, r, &reqParams, h.AppTracker)
if httpErr != nil {
httpErr.Render(w)
return
}

err := h.AccountService.DeregisterAccount(ctx, reqParams.Address)
if err != nil {
httperror.InternalServerError(ctx, "", err, nil).Render(w)
httperror.InternalServerError(ctx, "", err, nil, h.AppTracker).Render(w)
return
}

Expand Down
5 changes: 2 additions & 3 deletions internal/serve/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"github.com/stellar/go/support/render/health"
"github.com/stellar/go/xdr"
"github.com/stellar/wallet-backend/internal/apptracker"
"github.com/stellar/wallet-backend/internal/apptracker/sentry"
"github.com/stellar/wallet-backend/internal/data"
"github.com/stellar/wallet-backend/internal/db"
"github.com/stellar/wallet-backend/internal/entities"
Expand Down Expand Up @@ -61,7 +60,7 @@ type Configs struct {
ChannelAccountSignatureClient signing.SignatureClient

// Error Tracker
AppTracker sentry.SentryTracker
AppTracker apptracker.AppTracker
}

type handlerDeps struct {
Expand Down Expand Up @@ -163,7 +162,7 @@ func initHandlerDeps(cfg Configs) (handlerDeps, error) {
AccountService: accountService,
AccountSponsorshipService: accountSponsorshipService,
PaymentService: paymentService,
AppTracker: &cfg.AppTracker,
AppTracker: cfg.AppTracker,
}, nil
}

Expand Down

0 comments on commit 73a2f0a

Please sign in to comment.