Socket
Socket
Sign inDemoInstall

github.com/Xuanwo/storage

Package Overview
Dependencies
21
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/Xuanwo/storage

Package storage intend to provide a unified storage layer for Golang. - Production ready: high test coverage, enterprise storage software adaptation, semantic versioning, well documented. - High performance: more code generation, less runtime reflect. - Vendor agnostic: more generic abstraction, less internal details. There two main public interfaces: Servicer and Storager. Storager is a fully functional storage client, and Servicer is a manager of Storager instances, which will be useful for services like object storage. For any service, Storager is required to implement and Servicer is optional. The most common case to use a Storager service could be following: 1. Init a service. 2. Use Storager API to maintain data. - Storage uses error wrapping added by go 1.13, go version before 1.13 could be behaved as unexpected.


Version published

Readme

Source

storage

Build Status GoDoc Go Report Card codecov License Codacy Badge Join the chat

An application-oriented unified storage layer for Golang.

Goal

  • Production ready
  • High performance
  • Vendor agnostic

Features

Widely services support

Servicer operation support

  • List: list all Storager in service
  • Get: get a Storager via name
  • Create: create a Storager
  • Delete: delete a Storager

Storager operation support

Basic operations

  • Metadata: get storager's metadata
  • Read: read file content
  • Write: write content into file
  • Stat: get file's metadata
  • Delete: delete a file or directory

Extended operations

  • Copy: copy a file inside storager
  • Move: move a file inside storager
  • Reach: generate a public accessible url
  • Statistical: get storage service's statistics

Multiple list style support

  • ListDir: list files and directories under a directory
  • ListPrefix: list files under a prefix

Segment/Multipart support

  • ListPrefixSegment: list segments under a prefix
  • InitIndexSegment: initiate an index type segment
  • WriteIndexSegment: write content into an index type segment
  • CompleteSegment: complete a segment to create a file
  • AbortSegment: abort a segment

File metadata support

Required metadata

  • id: unique key in service
  • name: relative path towards service's work dir
  • size: size of this object
  • updated_at: last update time of this object

Optional metadata

  • content-md5: md5 digest as defined in rfc2616
  • content-type: media type as defined in rfc2616
  • etag: entity tag as defined in rfc2616
  • storage-class: object's storage class as defined in storage proposal

Quick Start

import (
    "log"

    "github.com/Xuanwo/storage"
    "github.com/Xuanwo/storage/coreutils"
    "github.com/Xuanwo/storage/types/pairs"
)

// Init a service.
store, err := coreutils.OpenStorager("fs", pairs.WithWorkDir("/tmp"))
if err != nil {
    log.Fatalf("service init failed: %v", err)
}

// Use Storager API to maintain data.
r, err := store.Read("path/to/file")
if err != nil {
    log.Printf("storager read: %v", err)
}

FAQs

Last updated on 30 Jun 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc