helix

Bucket

The bucket integration provides an opinionated and standardized way to interact with bucket providers through drivers.

The integration supports the following drivers:

  • AWS S3
  • Azure Blob Storage
  • Google Cloud Storage
  • Local files

Trace attributes

The bucket integration sets the following trace attributes:

  • bucket.driver
  • bucket.bucket
  • span.kind

When applicable, these attributes can be set as well:

  • bucket.key
  • bucket.key_source
  • bucket.key_destination
  • bucket.subfolder

Example:

bucket.driver: "aws"
bucket.bucket: "my-bucket"
bucket.key: "blob.json"
bucket.subfolder: "path/to/subfolder/"
span.kind: "client"

Usage

Install the Go module with:

$ go get go.nunchi.studio/helix/integration/bucket

Simple example on how to import, configure, and use the integration:

import (
  "context"

  "go.nunchi.studio/helix/integration/bucket"
  "go.nunchi.studio/helix/service"
)

func main() {
  cfg := bucket.Config{
    Driver:    bucket.DriverAWS,
    Bucket:    "my-bucket",
    Subfolder: "path/to/subfolder/",
  }

  b, err := bucket.Connect(cfg)
  if err != nil {
    return err
  }

  ctx := context.Background()
  blob, err := b.Read(ctx, "blob.json")
  if err != nil {
    // ...
  }

  var anything anyType
  err = json.Unmarshal(blob, &anything)
  if err != nil {
    // ...
  }

  if err := service.Start(); err != nil {
    panic(err)
  }

  if err := service.Close(); err != nil {
    panic(err)
  }
}

Is something missing?

Built by
Nunchi