All Projects → ebergstedt → Protobuffer

ebergstedt / Protobuffer

Licence: mit
A simple wrapper library for protobuf-net with async, gzip and less boilerplate.

Projects that are alternatives of or similar to Protobuffer

React Mobx React Router4 Boilerplate
React, React-Router 4, MobX and Webpack 2-boilerplate with async routes.
Stars: ✭ 566 (+1032%)
Mutual labels:  async, boilerplate
Datakernel
Alternative Java platform, built from the ground up - with its own async I/O core and DI. Ultra high-performance, simple and minimalistic - redefines server-side programming, web-development and highload!
Stars: ✭ 87 (+74%)
Mutual labels:  async, serialization
Reservoir
Android library to easily serialize and cache your objects to disk using key/value pairs.
Stars: ✭ 674 (+1248%)
Mutual labels:  async, serialization
React Social Network
Simple React Social Network
Stars: ✭ 409 (+718%)
Mutual labels:  async, boilerplate
Express Security
nodejs + express security and performance boilerplate.
Stars: ✭ 37 (-26%)
Mutual labels:  boilerplate, gzip
Beeschema
Binary Schema Library for C#
Stars: ✭ 46 (-8%)
Mutual labels:  serialization
Webxr Webpack Boilerplate
Starter Kit for building rich, immersive WebXR projects (featuring A-Frame) PWA with Webpack and SASS
Stars: ✭ 48 (-4%)
Mutual labels:  boilerplate
Express Mvc Boilerplate
A simple mvc boilerplate for express.js (gulp + expressjs + nodemon + browser-sync)
Stars: ✭ 46 (-8%)
Mutual labels:  boilerplate
Vim Grepper
👾 Helps you win at grep.
Stars: ✭ 1,030 (+1960%)
Mutual labels:  async
Generator Baukasten
Awesome!
Stars: ✭ 50 (+0%)
Mutual labels:  boilerplate
Rackula
Generate a static site from any rack middleware.
Stars: ✭ 49 (-2%)
Mutual labels:  async
Go Restful Api
An idiomatic Go REST API starter kit (boilerplate) following SOLID principles and Clean Architecture
Stars: ✭ 1,043 (+1986%)
Mutual labels:  boilerplate
Furatto Rails Start Kit
A rails app with Furatto, Devise, and Facebook Authentication perfect for hackathons!
Stars: ✭ 46 (-8%)
Mutual labels:  boilerplate
Vibe.d
Official vibe.d development
Stars: ✭ 1,043 (+1986%)
Mutual labels:  async
Create React Redux App
This project was bootstrapped with Create React App and Redux, Sass Structure.
Stars: ✭ 46 (-8%)
Mutual labels:  async
Before After Hook
wrap methods with before/after hooks
Stars: ✭ 49 (-2%)
Mutual labels:  async
Nuxt Box
Truffle, Nuxt and Vue boilerplate
Stars: ✭ 46 (-8%)
Mutual labels:  boilerplate
Bigbang
Android base project used by Xmartlabs team
Stars: ✭ 47 (-6%)
Mutual labels:  boilerplate
Parcel Vue Ts
📦 Boilerplate for Vue.js & Typescript, base on Parcel bundler.
Stars: ✭ 49 (-2%)
Mutual labels:  boilerplate
Emacs Async Await
Async/Await for Emacs
Stars: ✭ 47 (-6%)
Mutual labels:  async

ProtoBuffer

A simple wrapper library for protobuf-net with async, gzip and less boilerplate.

ProtoBuffer will remove some repetitive code declarations, like streams initializations and reading. It supports object to byte array or to file, with serialization and deserialization. It can also employ gzip. Just remember to keep track on which objects are gzipped or not when you deserialize them.

Performance report for ProtoBuf shows that it's one of the fastest serializers for C#. But what ProtoBuf is designed for is unprecedented speed of deserialization, with a very compact format. This makes it a prime candidate for your caching solution, such as using Redis together with ProtoBuf for extremely fast data transfer and deserialization. This is as of 2016 the solution deployed in production at Stack Overflow.

Usage

The test files are self-explanatory. Click below to go to the test files.

Protobuffer.SimpleSerializer helps with serialization.

Protobuffer.SimpleDeserializer helps with deserialization.

Here is a sample:

[TestCase(false)]
[TestCase(true)]
public void Given_an_object_Then_protobuf_serialize_and_deseserialize_with_byte(bool useGzip)
{
    var serialize = _simpleSerializer.ToStringValue(GetObjectWithProtobufContract(), gzipCompress: useGzip);

    Person deserialize = _simpleDeserializer.FromStringValue<Person>(serialize, gzipDecompress: useGzip);

    Assert.NotNull(deserialize); // True !!
}

Methods

Protobuffer.SimpleSerializer

string SaveToFile(
    object item,
    string filePath,
    FileMode fileMode = FileMode.Create,
    bool gzipCompress = false);

Task<string> SaveToFileAsync(
    object item, 
    string filePath,
    FileMode fileMode = FileMode.Create, 
    bool gzipCompress = false);

byte[] ToByteArray(
    object item,
    bool gzipCompress = false);

string ToStringValue(
    object item,
    bool gzipCompress = false);

Protobuffer.SimpleDeserializer

T FromFile<T>(
    string filePath, 
    bool gzipDecompress = false);

Task<T> FromFileAsync<T>(
    string filePath,
    bool gzipDecompress = false);

T FromByteArray<T>(
    byte[] value,
    bool gzipDecompress = false);

T FromStringValue<T>(
    string value,
    bool gzipDecompress = false);

Gzip?

In ProtoBuffer you may chose to employ Gzip. Your data can be Gzipped before it's serialized into the ProtoBuf format.

Gzip's purpose is primarily used to compress strings. That is why it's the preferred serialization format for webservers to serve html/javascript/css which are in a string format. If your data contains a lot of strings, then you may see a considerable size compression when using Gzip. Be aware though that Gzip can increase the size of your data should it not contain enough strings.

Helpful links

Protobuf-net: the unofficial manual

Google ProtoBuf documentation

ProtoBuf vs Json vs XML

Contributors

ebergstedt eridleyj

Contributing

Getting started with Git and GitHub

License

The MIT License (MIT)

Copyright (c) 2016 Erik Bergstedt

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].