Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCM client refactor #397

Merged
merged 3 commits into from
Jan 14, 2021
Merged

FCM client refactor #397

merged 3 commits into from
Jan 14, 2021

Conversation

rowanseymour
Copy link
Contributor

Moves to Mailroom instance alongside the elastic client, redis pool etc instead of being a global.

@codecov
Copy link

codecov bot commented Jan 14, 2021

Codecov Report

Merging #397 (4a36e5a) into master (4b23bc0) will increase coverage by 0.01%.
The diff coverage is 81.63%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #397      +/-   ##
==========================================
+ Coverage   55.17%   55.18%   +0.01%     
==========================================
  Files         115      115              
  Lines        7956     7949       -7     
==========================================
- Hits         4390     4387       -3     
+ Misses       2868     2864       -4     
  Partials      698      698              
Impacted Files Coverage Δ
core/models/runs.go 0.00% <0.00%> (ø)
core/tasks/starts/worker.go 55.43% <0.00%> (ø)
core/msgio/android.go 64.70% <50.00%> (+4.70%) ⬆️
core/tasks/broadcasts/worker.go 57.74% <50.00%> (ø)
core/runner/runner.go 46.51% <77.77%> (ø)
core/models/events.go 48.35% <80.00%> (ø)
core/tasks/handler/worker.go 50.00% <90.00%> (ø)
core/models/imports.go 69.76% <100.00%> (ø)
core/msgio/send.go 81.48% <100.00%> (ø)
core/tasks/campaigns/fire_campaign_event.go 39.28% <100.00%> (ø)
... and 9 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4b23bc0...4a36e5a. Read the comment docs.

@@ -133,7 +133,7 @@ func handleSubmit(ctx context.Context, s *web.Server, r *http.Request) (interfac
if err != nil {
return nil, http.StatusInternalServerError, errors.Wrapf(err, "error starting transaction for session write")
}
sessions, err := models.WriteSessions(ctx, tx, s.RP, oa, []flows.Session{fs}, []flows.Sprint{sprint}, nil)
sessions, err := models.WriteSessions(ctx, tx, s.RP, nil, oa, []flows.Session{fs}, []flows.Sprint{sprint}, nil)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

surveyor sessions shouldn't be sending android messages

@@ -237,7 +238,7 @@ func HandleAndCommitEvents(ctx context.Context, db QueryerWithTx, rp *redis.Pool
}

// ApplyModifiers modifies contacts by applying modifiers and handling the resultant events
func ApplyModifiers(ctx context.Context, db QueryerWithTx, rp *redis.Pool, oa *OrgAssets, modifiersByContact map[*flows.Contact][]flows.Modifier) (map[*flows.Contact][]flows.Event, error) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

modifiers don't send messages so don't need redis (for talking to courier) or the FCM client (for talking to Android)

Copy link
Member

@nicpottier nicpottier left a comment

Choose a reason for hiding this comment

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

I'm not sure this feels better to me, the hook interface changing seems especially ugly now, but if you really want it, go for it.

@rowanseymour
Copy link
Contributor Author

rowanseymour commented Jan 14, 2021

I started to have my doubts realising how many places need to pass it around but I think I still prefer the functional approach and if we're worried about function argument bloat we could possibly pack things like this into a context structure.

@rowanseymour rowanseymour merged commit bfc9340 into master Jan 14, 2021
@rowanseymour rowanseymour deleted the fcm_client_refactor branch January 14, 2021 16:58
@nicpottier
Copy link
Member

Does FCMClient really have any state that is interesting? Maybe our problem is having that be an object in the first place?

@nicpottier
Copy link
Member

Looking at it it is basically just an http.Client, so it really isn't maintaining much state over just the config. I don't know, it isn't the end of the world for sure, but just really feels wrong to have the Hook stuff even know about FCMClient, especially given how rarely it is used.

@rowanseymour
Copy link
Contributor Author

What's the difference between hooks knowing about redis.Pool and knowing about fcm.Client ?

@nicpottier
Copy link
Member

To me it is that redis/sql are more generically used by other hooks. They also actually have state beyond just configs (pools for the connections).

@rowanseymour
Copy link
Contributor Author

Ok so what do you want to do now that this is merged? I don't feel very strongly in favor of this so if you feel it's really wrong then I can revert it.

@nicpottier
Copy link
Member

I approved it so I can live with it. :)

rowanseymour added a commit that referenced this pull request Jan 14, 2021
This reverts commit bfc9340, reversing
changes made to 4b23bc0.
@rowanseymour
Copy link
Contributor Author

I've reverted it for now so can ponder on it a bit more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants