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

Create a users-sync singleton service to periodically send info to external services #2295

Merged
merged 18 commits into from
Sep 25, 2018

Conversation

leth
Copy link

@leth leth commented Sep 17, 2018

Almost there, just a few loose ends to tie up, but I'd appreciate any comments you have or things you spot at this stage.

Towards https://github.com/weaveworks/service-ui/issues/2812 and https://github.com/weaveworks/service-ui/issues/2836

@leth leth requested a review from rndstr September 17, 2018 16:42
@leth leth changed the title [WIP] Create a users-sync singleton service to do periodic work [WIP] Create a users-sync singleton service to periodically send info to external services Sep 17, 2018
@rndstr
Copy link

rndstr commented Sep 17, 2018

looks good to me so far!

@leth leth force-pushed the users-sync branch 6 times, most recently from ee0cd7c to 4fd3a46 Compare September 19, 2018 16:58
@leth leth changed the title [WIP] Create a users-sync singleton service to periodically send info to external services Create a users-sync singleton service to periodically send info to external services Sep 19, 2018
@leth
Copy link
Author

leth commented Sep 19, 2018

@rndstr I think I'm happy with this now; it works locally and has sent data to https://app.segment.com/weave-cloud/sources/weave_cloud_dev/debugger :)

@leth leth force-pushed the users-sync branch 2 times, most recently from 02a1287 to 836e8a9 Compare September 20, 2018 09:14
@leth
Copy link
Author

leth commented Sep 20, 2018

Hmm, I need to look at whether the prom metrics endpoint is exposed.

@leth
Copy link
Author

leth commented Sep 20, 2018

Commit 2569ec6 removes the need for weaveworks/common#128; I didn't intentionally introduce the loadbalancer, it crept in while refactoring.

Copy link

@rndstr rndstr left a comment

Choose a reason for hiding this comment

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

couple of comments, other than that the code looks good 👌
i did build and deploy it to my cluster but did not run any of the hot paths. if you would rather have me to, feel free to request another review.

)

// GetBillingStatus returns a single overall summary of the user's account.
func GetBillingStatus(ctx context.Context, trialInfo trial.Trial, acct *zuora.Account) (grpc.BillingStatus, string, string) {

This comment was marked as abuse.

}

func (c *AttributeSyncer) syncUsers(ctx context.Context, userFilter filter.User) error {
// page starts at 1 because 0 is "all pages"

This comment was marked as abuse.

"github.com/weaveworks/common/instrument"
)

func instrumetation(errorKey string, durationCollector *instrument.HistogramCollector) []grpc.DialOption {

This comment was marked as abuse.

orgBillingStatusCount := map[string]int{}
for statusInt, name := range billing_grpc.BillingStatus_name {
status := billing_grpc.BillingStatus(statusInt)
attributeName := fmt.Sprintf(orgsAttrPrefix+"status_%s_total", strings.ToLower(name))

This comment was marked as abuse.

resp, err := c.billingClient.GetInstanceBillingStatus(
ctx, &billing_grpc.InstanceBillingStatusRequest{InternalID: org.ID},
)
if err == nil {

This comment was marked as abuse.

findAndCleanTotal.Inc()
ids, err := c.db.FindUncleanedOrgIDs(ctx)
if err != nil {
log.Warnf("cannot find uncleaned org IDs, error: %s", err)
c.log.Warnf("cannot find uncleaned org IDs, error: %s\n", err)

This comment was marked as abuse.

This comment was marked as abuse.


// MatchesUser users who have logged in since the given time.
func (s NotLoggedInSince) MatchesUser(u users.User) bool {
return u.LastLoginAt.Before(time.Time(s)) || u.LastLoginAt.Equal(time.Time(s))

This comment was marked as abuse.

@@ -213,7 +213,6 @@ func (d DB) listDirectOrganizationUsers(ctx context.Context, orgExternalID strin
Where(squirrel.Eq{
"organizations.external_id": orgExternalID,
"memberships.deleted_at": nil,
"organizations.deleted_at": nil,

This comment was marked as abuse.

This comment was marked as abuse.

Marcus Cobden added 2 commits September 24, 2018 11:04
@leth leth merged commit 79a28c0 into master Sep 25, 2018
@leth leth deleted the users-sync branch September 25, 2018 14:42
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