inhabitedtype / faraday Goto Github PK
View Code? Open in Web Editor NEWSerialization library built for speed and memory efficiency
License: Other
Serialization library built for speed and memory efficiency
License: Other
May be a bug in dune
but it seems that if we use faraday
as a vendor (available into a dune workspace of another project), dune
is not able to compile anything due to a missing dune-project
.
As angstrom
, distribution of faraday
should have a dune-project
to be able to use it as a vendor library.
PS: I don't really know the real issue, hwever :/
Small typo - PR incoming.
When writing to a closed Faraday.t
an exception Failure "cannot write to closed writer"
is raised. I am observing this exception from Httpaf.Body.write_string
, and I'm wary of catching all Failure
s. Could a more precise exception be used?
Lines 193 to 195 in c66fc02
Introduced in #19 to fix a pretty bad bug. Before the next release, eliminate the allocation on every flush, allowing the library to use additional free space in the buffer across flushes. As part of this fix, ensure that write_pos
and schedule_pos
are reset to 0
when they're equal and the flush queue is empty.
Hi - is there a simple way of testing if a Faraday.t is empty? Thanks
Could you expand the README to explain the scope of the serialiser? Looking at the interface it is not obvious how to serialise user-defined types. Maybe this is not even a design goal. In any case, I think the README could address this.
(reported against Eio in ocaml-multicore/eio#418, which contains fixes and tests)
Lines 290 to 297 in c66fc02
@adatario noticed that the shifts should be in bits, not bytes.
Also, the BE version gets the sizes of the chunks wrong (should be 16 then 32).
Faraday already requires an OCaml version after 4.02.0, which includes all the bigarray intrinsics that are needed to efficiently implement little- and big-endian blitting operations. Eliminate the dependency and just use the intrinsics directly.
Comes from the blit
call in write_gen
.
I'm trying to use faraday with Async like so:
open Async
let handle fd =
let ic = Reader.create fd in
let writev = Faraday_async.writev_of_fd fd in
let output_buffer = Faraday.create 16 in
let write_output x =
Faraday_async.serialize output_buffer
~yield:(fun buffer -> my_serialize_function buffer x |> return)
~writev
in
Angstrom_async.parse_many parse_function
(fun parsed -> parsed |> my_processing_function |> write_output)
ic
>>| Result.get_ok
let create_server port =
Tcp.Server.create_sock_inet ~on_handler_error:`Raise
(Tcp.Where_to_listen.of_port port) (fun _address socket ->
handle (Socket.fd socket))
but I get this error any time I try to connect:
((monitor.ml.Error "Assert_failure lib/faraday.ml:377:4"
("Raised at file \"async/faraday_async.ml\", line 30, characters 6-15"
"Called from file \"src/deferred1.ml\", line 17, characters 40-45"
"Called from file \"src/job_queue.ml\", line 167, characters 6-47"
"Caught by monitor Tcp.Server.create_sock_inet"))
Any idea why this might be happening?
Hi, I needed a buffered writer in Eio, and I used Faraday as the basis of that (ocaml-multicore/eio#235). While reviewing the code, I fixed a few things that might want fixing here too.
There is a comment in shift_flushes
saying that it avoids overflow problems by subtracting both sides:
Lines 392 to 410 in 3ea082b
This doesn't work; it just shifts the problem elsewhere (consider bytes_written = -2
and threshold = 8
, for example). I believe the test should be t.bytes_written - threshold >= 0
. /cc @dinosaure
write_string
and write_bytes
both perform unsafe blits using offsets provided by the user:
Lines 250 to 258 in 3ea082b
If the user's writev
function returns Closed
then it can't consume anything and just calls it again, forever:
Lines 436 to 444 in 3ea082b
BTW, Faraday uses the BSD-3-clause license, whereas Eio uses ISC. I included your headers and license in Eio, but if you're willing to let us use it as ISC it would simplify things slightly.
I'm still trying to minimize the steps and narrow down what's going on, but from a utop session the following will fail with Exception: Assert_failure ("lib/faraday.ml", 477, 4).
using the faraday 0.3.0 from opam:
let f = Faraday.create 1;;
Faraday.schedule_string f "hello world";;
Faraday.schedule_string f "hello world";;
Faraday.schedule_string f "hello world";;
Faraday.schedule_string f "hello world";;
Faraday.serialize_to_string f;;
The real error came from a larger buffer with a lot more input. I may also be using the library very incorrectly.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.