Giter Site home page Giter Site logo

Comments (3)

pavlospt avatar pavlospt commented on May 4, 2024 1

Just a small note here, if you are using GSON you can very easily convert your Stock object to a BufferedSource.

Buffer buffer = new Buffer();
Gson gson = new Gson();
buffer.write(gson.toJson(yourObjectGoesHere).getBytes());
buffer.flush();
buffer.close();

from store.

digitalbuddha avatar digitalbuddha commented on May 4, 2024

Currently the file system impelentation needs a stream from network. As a result SourcePersisterFactory cannot work with an input of a scalar value like Stock. What you can do is write your own persister which can still use the FileSystem, within your read/write impelentation you can do the conversion from your data type to a BufferedSource. Use the SourcePersisterFactory as an example (there should be a test for it which shows how to create a bufferedsource from a string)

You're also free to create a new middleware for this and we will merge it in. ☺️

Alternatively you can use your own persister without our file system and write a persister implementation that can work with an input/output of Stock.

from store.

digitalbuddha avatar digitalbuddha commented on May 4, 2024

one more helper method how to go from a string to a bufferedsource

private static BufferedSource source(String data) {
        return Okio.buffer(Okio.source(new ByteArrayInputStream(data.getBytes(UTF_8))));
    }

from store.

Related Issues (20)

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.