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

Support mongodb+srv:// in image store, increase timeout on 30s #129

Merged
merged 1 commit into from
Oct 2, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions avatar/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,13 @@ func NewStore(uri string) (Store, error) {
return NewLocalFS(strings.TrimPrefix(uri, "file://")), nil
case !strings.Contains(uri, "://"):
return NewLocalFS(uri), nil
case strings.HasPrefix(uri, "mongodb://"):

case strings.HasPrefix(uri, "mongodb://"), strings.HasPrefix(uri, "mongodb+srv://"):
db, bucketName, u, err := parseExtMongoURI(uri)
if err != nil {
return nil, fmt.Errorf("can't parse mongo store uri %s: %w", uri, err)
}

ctx, cancel := context.WithTimeout(context.Background(), time.Second)
ctx, cancel := context.WithTimeout(context.Background(), time.Second*30)
defer cancel()

client, err := mongo.Connect(ctx, options.Client().ApplyURI(u))
Expand Down