-
Notifications
You must be signed in to change notification settings - Fork 499
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
index/cmd/single read from txmeta files
- Loading branch information
Paul Bellamy
committed
Apr 26, 2022
1 parent
38652e2
commit ebf37a7
Showing
4 changed files
with
120 additions
and
95 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
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,31 @@ | ||
package index | ||
|
||
import ( | ||
"errors" | ||
"net/url" | ||
"path/filepath" | ||
|
||
"github.com/aws/aws-sdk-go/aws" | ||
) | ||
|
||
func Connect(backendUrl string) (Store, error) { | ||
parsed, err := url.Parse(backendUrl) | ||
if err != nil { | ||
return nil, err | ||
} | ||
switch parsed.Scheme { | ||
case "s3": | ||
config := &aws.Config{} | ||
query := parsed.Query() | ||
if region := query.Get("region"); region != "" { | ||
config.Region = aws.String(region) | ||
} | ||
return NewS3Store(config, parsed.Path, 20) | ||
|
||
case "file": | ||
return NewFileStore(filepath.Join(parsed.Host, parsed.Path), 20) | ||
|
||
default: | ||
return nil, errors.New("unknown URL scheme: '" + parsed.Scheme + "'") | ||
} | ||
} |
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