Git Product home page Git Product logo

namotion.storage's Introduction

Namotion.Storage

Storage | Messaging | Reflection

Azure DevOps Azure DevOps

The Namotion.Storage .NET libraries provide abstractions and implementations for storage services like blob storages, file systems or object storages.

By programming against a storage abstraction you enable the following scenarios:

  • Build multi-cloud capable applications by being able to change storage technologies on demand.
  • Quickly switch to different storage technologies to find the best technological fit for your applications.
  • Implement behavior driven integration tests which can run in-memory or against different technologies for better debugging experiences or local execution.
  • Provide better local development experiences, e.g. replace Azure Blob Storage with the local file system or an in-memory implementation.

Usage

In your application root, create an IBlobStorage instance with an actual implementation package and retrieve a blob container:

var storage = AzureBlobStorage.CreateFromConnectionString("MyConnectionString");
IBlobContainer container = storage.GetContainer("MyContainer");
IBlobContainer<Person> typedContainer = container.WithBlobType<Person>();

await typedContainer.WriteJsonAsync("MyPath", new Person { ... });
var person = await typedContainer.ReadJsonAsync("MyPath");

In your business service classes you should then only use the abstraction interfaces like IBlobContainer or IObjectStorage, etc.

Core packages

Namotion.Storage.Abstractions

Nuget Apimundo

Blobs

Inject IBlobStorage or IBlobContainer but do not get a container from a blob storage in the consuming class (violates SRP).

  • IBlobStorage: A blob storage where blobs are stored in a container and cannot be directly stored. Only containerName/blobName or containerName/subDirectories/blobName are allowed.
  • IBlobContainer<T>
  • IBlobContainer: A blob container where blobs can be directly stored or in a subdirectory. A container acts like a simple/basic virtual file system.
    • OpenWriteAsync: Creates or overrides an existing blob
    • OpenAppendAsync: Creates or appends to an existing blob
    • OpenReadAsync
    • ExistsAsync
    • GetAsync
    • ListAsync
    • DeleteAsync: Deletes a blob
  • BlobElement: Metadata and properties of a blob or container.

Internal:

  • IBlobReader: Internal (do not use directly.)
  • IBlobWriter: Internal (do not use directly.)

The idea behind the generic interfaces is to allow multiple instance registrations, read Dependency Injection in .NET: A way to work around missing named registrations for more information.

Objects

  • IObjectStorage<T>
    • WriteAsync(id, value)
    • ReadAsync(id)
    • DeleteAsync(id)

Namotion.Storage.Json

Nuget Apimundo

Extension methods:

  • WriteAsJson(): Writes an object as JSON into a blob container/storage.
  • ReadAsJson(): Reads an object as JSON from a blob container/storage.
  • CreateJsonObjectStorage<T>(): Creates an IObjectStorage<T> for a given IBlobContainer. Usage: var objectStorage = blobContainer.CreateJsonObjectStorage<Person>().

Implementation packages

The following packages should only be used in the head project, i.e. directly in your application bootstrapping project where the dependency injection container is initialized.

Namotion.Storage

Nuget Apimundo

Implementations:

  • FileSystemBlobStorage
  • InMemoryBlobStorage

Extensions:

  • WithBlobType<T>(): Adds a blob type to an IBlobStorage/IBlobContainer and transforms it into a IBlobStorage<T>/IBlobContainer<T>.
  • Wrap<T>()/Wrap(): Adds an interceptor to the blob storage (blobStorage.Wrap(s => new MyInterceptor(s))). An interceptor can be implemented as a new class inheriting from the BlobStorage class and overriding some methods.

Namotion.Storage.Azure.Storage.Blob

Nuget Apimundo

Implementations:

  • AzureBlobStorage

Namotion.Storage.Ftp

Nuget Apimundo

Implementations:

  • FtpBlobStorage

namotion.storage's People

Contributors

ricosuter avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.