-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚤 improve performance for large slack accounts (#3142)
If you are a large organisation with 1000s of conversations, the previous implementation fetched information about the creator via the user rest call. The problem is that the slack api heavily rate limits the user rest call. This change makes the creator information asynchronous and therefore allows much speedier fetching of the conversations. This avoids reaching the rate limit.
- Loading branch information
1 parent
113d7f3
commit 2c73f3f
Showing
5 changed files
with
83 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright (c) Mondoo, Inc. | ||
// SPDX-License-Identifier: BUSL-1.1 | ||
|
||
//go:build debugtest | ||
// +build debugtest | ||
|
||
package connection | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
|
||
"github.com/slack-go/slack" | ||
"github.com/stretchr/testify/require" | ||
"go.mondoo.com/cnquery/v10/providers-sdk/v1/inventory" | ||
"go.mondoo.com/cnquery/v10/providers-sdk/v1/vault" | ||
) | ||
|
||
func TestSlackProvider(t *testing.T) { | ||
|
||
cred := &vault.Credential{ | ||
Type: vault.CredentialType_password, | ||
Password: "<slack-token>", | ||
} | ||
cred.PreProcess() | ||
|
||
conn, err := NewSlackConnection(1, &inventory.Asset{}, &inventory.Config{ | ||
Type: "slack", | ||
Credentials: []*vault.Credential{cred}, | ||
}) | ||
require.NoError(t, err) | ||
|
||
client := conn.Client() | ||
ctx := context.Background() | ||
users, err := client.GetUsersContext(ctx, slack.GetUsersOptionLimit(999)) | ||
require.NoError(t, err) | ||
require.NotNil(t, users) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.