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

Feature/team events #35

Merged
merged 1 commit into from
Aug 4, 2017
Merged

Feature/team events #35

merged 1 commit into from
Aug 4, 2017

Conversation

jschaul
Copy link
Member

@jschaul jschaul commented Jul 25, 2017

Introduces journaling via AWS SQS for team events (create, update, delete).

  • Team deletions become soft deletes (to allow for eventual consistency on the journal consumer side: a cassandra table scan allows for re-creating create/delete events)
  • types-common-journal depends on protoc at compile time for protobuf code generation.
  • Journaling in galley is optional at run time (via optional ---team-events-queue-name and --aws-region params) and at integration test time (via an optional GALLEY_SQS_TEAM_EVENTS environment variable) to allow galley to function without SQS.
  • integration tests consume SQS events, making them slower (from ~90s to ~110s) (to be improved)

@jschaul jschaul requested a review from tiago-loureiro July 25, 2017 15:16
rsp <- Data.deleteTeam tid
when ((view teamBinding . Data.tdTeam <$> team) == Just Binding) $
journal $ Journal.teamDelete tid
return rsp
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we reverse this, i.e., deleteTeamshould probably be done after the journaling as that'd guarantee that we journal the event at least once

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense in this case.


teamCreate :: TeamId -> UserId -> IO TeamEvent
teamCreate tid uid = do
now <- utcTimeToInt64 <$> liftIO getCurrentTime
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of requiring a new library, how about using utcTimeToPOSIXSeconds which is part of time?

> n <- getCurrentTime
> n
2017-07-26 12:52:28.373924 UTC
> utcTimeToInt64 n
1501073548
> round (utcTimeToPOSIXSeconds n) :: Int64
1501073548

rsp <- addTeamMemberInternal tid Nothing Nothing nmem mems
let membs = nmem^.ntmNewTeamMember : mems
let bUsers = view userId <$> filter (`hasPermission` SetBilling) membs
journal $ Journal.teamUpdate tid (fromIntegral $ length membs) bUsers
Copy link
Contributor

Choose a reason for hiding this comment

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

I noticed that

let membs = filter (\u -> u^.userId /= remove) mems
let bUsers = view userId <$> filter (`hasPermission` SetBilling) membs
 $ Journal.teamUpdate tid (fromIntegral $ length membs) bUsers

is a recurring pattern, with only slight variation on how membs is constructed. Can we refactor that?

mEnv <- view aEnv
for_ mEnv $ \e -> do
event <- liftIO ev
void $ Aws.execute e (Aws.enqueue event)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you don't need this void here

either (throwM . GeneralError) (const (return ())) res
where
event = decodeLatin1 $ B64.encode $ encodeMessage e
req url = SQS.sendMessage url event & SQS.smMessageGroupId .~ Just "team.events"
Copy link
Contributor

Choose a reason for hiding this comment

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

Just nitpicking here but should we define this somewhere else since it should be used by consumers too?

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you referring to the MessageGroupId? This is only relevant when sending to a FIFO queue, consumers don't need to know about it:

Receiving Messages
You can't request to receive messages with a specific message group ID.

@jschaul jschaul force-pushed the feature/team-events branch 13 times, most recently from 3d8d59e to 827858c Compare August 4, 2017 09:55
Introduces journaling via AWS SQS for team events (create, update, delete).

* Team deletions become soft deletes (to allow for eventual consistency
on the journal consumer side: a cassandra table scan allows for
re-creating create/delete events)
* types-common-journal depends on `protoc` at compile time for protobuf code generation.
* Journaling in galley is optional at run time (via optional `---team-events-queue-name`
  and `--aws-region` params) and at integration test time (via an optional `GALLEY_SQS_TEAM_EVENTS`
  environment variable) to allow galley to function without SQS.
* integration tests consume SQS events, making them slower (from ~90s to ~110s) (to be improved)
@jschaul jschaul force-pushed the feature/team-events branch from 827858c to 621b5fb Compare August 4, 2017 10:12
@jschaul jschaul merged commit 7c1f0d4 into develop Aug 4, 2017
@jschaul jschaul deleted the feature/team-events branch August 4, 2017 10:16
flokli pushed a commit that referenced this pull request Jul 1, 2020
* ListResponse is 1-indexed, not 0-indexed

* implement patch in terms of get and put

* Implements patch _only_ for userName, displayName, externalId

* Add Azure acceptance test

Co-authored-by: fisx <mf@zerobuzz.net>
smatting pushed a commit that referenced this pull request Apr 20, 2022
…s components (#35)

* add a first scenario explaining cert renewal for a 3-master K8s v1.14 setup installed with Kubespray
* add additional structure to reflect (fingers crossed) future k8s content
* typo

* Minor changes, add one paragraph

Co-authored-by: jschaul <jschaul@users.noreply.github.com>
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