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

docs(README): include some notes on logging and integration tests #12

Merged
merged 1 commit into from
Sep 17, 2023
Merged
Show file tree
Hide file tree
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
33 changes: 31 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,32 @@

This package provides an S3 implementation for [Go1.16 filesystem interface](https://tip.golang.org/doc/go1.16#fs).

# Overview

This package provides an S3 implementation for the Go1.16 filesystem interface using the [AWS SDK for Go v2](https://github.com/aws/aws-sdk-go-v2).

The `S3FS` is currently read-only, and implements the following interfaces:

- `fs.FS`
- `fs.StatFS`
- `fs.ReadDirFS`

The `s3File` implements the following interfaces:

- `fs.FileInfo`
- `fs.DirEntry`
- `io.ReaderAt`
- `io.Seeker`

This enables libraries such as [apache arrow](https://arrow.apache.org/) to read parts of a parquet file from S3, without downloading the entire file.
# Usage

```go
// Load the Shared AWS Configuration (~/.aws/config)
awscfg, err := config.LoadDefaultConfig(context.TODO())
// Load the Shared AWS Configuration (~/.aws/config) and enable request logging
awscfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithClientLogMode(aws.LogRetries|aws.LogRequest),
config.WithLogger(logging.NewStandardLogger(os.Stdout)),
)
if err != nil {
// ...
}
Expand All @@ -30,6 +51,14 @@ This package provides an S3 implementation for [Go1.16 filesystem interface](htt
}
```

# Integration Tests

The integration tests for this package are in a separate module under the `integration` directory, this to avoid polluting the main module with docker based testing dependencies used to run the tests locally against [minio](https://min.io/).

# Links

S3 implements ranges based on [HTTP Request ranges](https://developer.mozilla.org/en-US/docs/Web/HTTP/Range_requests), it well worth reading up on this if your using the `io.ReadSeek` interface.

# License

This application is released under Apache 2.0 license and is copyright [Mark Wolfe](https://www.wolfe.id.au).
9 changes: 7 additions & 2 deletions example/walk.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@ import (
"io/fs"
"os"

"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/config"
"github.com/aws/aws-sdk-go-v2/service/s3"
"github.com/aws/smithy-go/logging"
"github.com/rs/zerolog/log"
"github.com/wolfeidau/s3iofs"
)

func main() {
// Load the Shared AWS Configuration (~/.aws/config)
awscfg, err := config.LoadDefaultConfig(context.TODO())
// Load the Shared AWS Configuration (~/.aws/config) and enable request logging
awscfg, err := config.LoadDefaultConfig(context.TODO(),
config.WithClientLogMode(aws.LogRetries|aws.LogRequest),
config.WithLogger(logging.NewStandardLogger(os.Stdout)),
)
if err != nil {
log.Fatal().Err(err).Msg("failed to load aws config")
}
Expand Down
Loading