-
Notifications
You must be signed in to change notification settings - Fork 2
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
Conversation
looks good to me so far! |
ee0cd7c
to
4fd3a46
Compare
@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 :) |
02a1287
to
836e8a9
Compare
Hmm, I need to look at whether the prom metrics endpoint is exposed. |
Commit 2569ec6 removes the need for weaveworks/common#128; I didn't intentionally introduce the loadbalancer, it crept in while refactoring. |
There was a problem hiding this 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.
billing-api/api/accounts.go
Outdated
) | ||
|
||
// 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.
This comment was marked as abuse.
Sorry, something went wrong.
} | ||
|
||
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.
This comment was marked as abuse.
Sorry, something went wrong.
common/grpc/client.go
Outdated
"github.com/weaveworks/common/instrument" | ||
) | ||
|
||
func instrumetation(errorKey string, durationCollector *instrument.HistogramCollector) []grpc.DialOption { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
users-sync/attrsync/org_attrs.go
Outdated
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.
This comment was marked as abuse.
Sorry, something went wrong.
users-sync/attrsync/org_attrs.go
Outdated
resp, err := c.billingClient.GetInstanceBillingStatus( | ||
ctx, &billing_grpc.InstanceBillingStatusRequest{InternalID: org.ID}, | ||
) | ||
if err == nil { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
users/db/filter/user.go
Outdated
|
||
// 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.
This comment was marked as abuse.
Sorry, something went wrong.
users/db/postgres/organization.go
Outdated
@@ -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.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Since this will only return results about a specific org, if you're asking about a deleted organisation, you probably know it was deleted.
Also factor out common GRPC client instrumentation
To avoid any unexpected behaviour
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