rotate-writer

module
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 5, 2021 License: Apache-2.0

README

rotate-writer

rotate-writer is a golang library that implements the io.Writer interface and that can be used to implement some sort of rotation for files based on the given bytes so they cannot grow without bounds.

currently rotate-writer supports 3 different writer targets

  • File
  • S3
  • Azure Blob Storage

Usage

go get -u github.com/arnobroekhof/rotate-writer
File
package examples

import (
    "fmt"
    "github.com/arnobroekhof/rotate-writer/file"
)

func someFunction() {
    d1 := []byte("hello\ngo\n")
    w, err := file.NewFileRotateWriter("/some/destination", 10240000) // set rotation size to 10MB

    if err != nil {
        panic(err)
    }

    defer w.Close()

    _, err = w.Write(d1)
    if err != nil {
        fmt.Println(err)
    }

}
S3
package examples

import (
    "fmt"
    "github.com/arnobroekhof/rotate-writer/s3"
)

func filewriting() {
    d1 := []byte("hello\ngo\n")
    w, err := s3.NewS3RotateWriter("s3.amazonaws.com","somebucket", "/some.object.name", ".txt", "eu-west-1", "some-access-key", "some-secret-key",true ,10240000)
    
    if err != nil {
        panic(err)
    }

    defer w.Close()

    _, err = w.Write(d1)
    if err != nil {
        fmt.Println(err)
    }

}
Azure Blob Storage
package examples

import (
    "fmt"
    "github.com/arnobroekhof/rotate-writer/azure"
)

func filewriting() {
    d1 := []byte("hello\ngo\n")

    w, err := azure.NewAzureBlobRotateWriter("storageAccount", "storageAccessKey", "containerName", "objectName", 10240000, "")

    if err != nil {
        panic(err)
    }

    defer w.Close()

    _, err = w.Write(d1)
    if err != nil {
        fmt.Println(err)
    }

}

TODO

  • File Writer
  • S3 Writer
  • Azure Blob Storage Writer
  • Google Cloud Storage Writer
  • Implement compression
  • Implement custom rotation name instead of date
  • Create Examples
  • Use github actions for releases and linting
  • Add Go Docs

Directories

Path Synopsis
pkg
s3

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL