Giter Site home page Giter Site logo

Comments (5)

matryer avatar matryer commented on June 14, 2024

Good question.

We wanted to provide a common interface for all codecs, and since (at the time of initial writing) the JSON encoder used simple marshal/unmarshal methods (i.e. no Encoders which I believe were added later) we went with that.

If you'd like to contribute to designing codecs2, we'd love your input.

On 3 Sep 2013, at 22:11, Tamás Gulácsi [email protected] wrote:

Why do you encode/marshal into a freshly allocated []byte, and do you require a []byte for unmarshal? Even proper encodings/csv is hidden behind this memory-hungry, nonscalable interface...


Reply to this email directly or view it on GitHub.

from codecs.

tgulacsi avatar tgulacsi commented on June 14, 2024

Thanks for the positive response!

My use case is a niche, but I have to send unlimited data (records from database query resultset) to the client.
I use a hand-made encoder which marshals the result records one after another, and writes them in sequence - thus never more is in memory than one marshaled record.

The generalization is a little bit harder: how should we represent such an iterator-like interface?
Maybe we could define a

type Iterable interface {
Next() interface{}
}

and specialize the marshaler for it - but first a real-world use case would be needed.

The usage of io.Reader / io.Writer is easier, though.

from codecs.

matryer avatar matryer commented on June 14, 2024

Even without the io.Reader and io.Writer interface, you could use codecs, and just write each response out like you do with your hand-made encoder. At least that way, you could still get the benefit of multiple formats.

An interesting problem.

On 3 Sep 2013, at 23:36, Tamás Gulácsi [email protected] wrote:

Thanks for the positive response!

My use case is a niche, but I have to send unlimited data (records from database query resultset) to the client.
I use a hand-made encoder which marshals the result records one after another, and writes them in sequence - thus never more is in memory than one marshaled record.

The generalization is a little bit harder: how should we represent such an iterator-like interface?
Maybe we could define a

type Iterable interface {
Next() interface{}
}

and specialize the marshaler for it - but first a real-world use case would be needed.

The usage of io.Reader / io.Writer is easier, though.


Reply to this email directly or view it on GitHub.

from codecs.

tylerstillwater avatar tylerstillwater commented on June 14, 2024

@tgulacsi @matryer has this issue been resolved? Does it need further discussion? I would like to close it if possible.

from codecs.

matryer avatar matryer commented on June 14, 2024

I think it should go to designing codecs2 - streaming is definitely a better interface.

On Feb 5, 2014, at 11:31 AM, Tyler [email protected] wrote:

@tgulacsi @matryer has this issue been resolved? Does it need further discussion? I would like to close it if possible.


Reply to this email directly or view it on GitHub.

from codecs.

Related Issues (19)

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.