<doublec>
ashp: I don't know of any production quality http server
<ashp>
a toy example will do for some tinkering around, thanks!
<jemc>
ashp: the intent is that someone with the need and the skills will rewrite the `net/http` package to be less proof-of-concept and more serious and production-ready
<ashp>
sadly I'm not a competent anything so that'll never be me, but it'll at least let me play around and get a feel for the language :)
<jemc>
great, and feel free to ask in here when you hit snags
<jemc>
(or on the mailing list for a more long-form conversation)
<doublec>
ashp: I've used the http server in a project if you have any questions
aturley has joined #ponylang
aturley has quit [Ping timeout: 240 seconds]
gmcabrita has quit [Quit: Connection closed for inactivity]
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
SilverKey has joined #ponylang
SilverKey has quit [Client Quit]
SilverKey has joined #ponylang
copy` has quit [Quit: Connection closed for inactivity]
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
graaff has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Max SendQ exceeded]
SilverKey has joined #ponylang
SilverKey has quit [Client Quit]
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
rurban has joined #ponylang
amclain has quit [Quit: Leaving]
aturley has joined #ponylang
<doublec>
If have two promises, p1 and p2, can I have a third promise run only when both p1 and p2 are fulfilled?
aturley has quit [Ping timeout: 265 seconds]
<doublec>
I want to send off two async requests and do something with the results when both complete
trapped has joined #ponylang
<jemc>
doublec: I don't think such a utility class currently exists in the promises package - you'd have to write it yourself
<jemc>
effectively you'd want to create an actor called something like `PromiseJoin2[A1,A2]`
<jemc>
and you'd need it to produce some glue objects as the fulfill or reject functions to pass to the source promises
trapped has quit [Read error: Connection reset by peer]
<jemc>
one way to do this is to have some `fun tag`s on that actor that can produce the fullfill and reject functions
<jemc>
they would contain the tag reference to the PromiseJoin2 actor, and could send it an appropriate message to mark fulfillment
<doublec>
Thanks, that's I'm writing something similar to that but not generic. If I get it working I'll try and make it generic.
<jemc>
yeah, I think it would probably be nice to have some generic utlity classes like that in the promises package
tm-exa has joined #ponylang
jemc has quit [Ping timeout: 260 seconds]
aturley has joined #ponylang
aturley has quit [Ping timeout: 252 seconds]
tm-exa has quit [Quit: Computer has gone to sleep]
<doublec>
That last p(42) should be p2(do_something())
<jonas-l>
to me it looks weird..
<jonas-l>
I think rpc.run() should return
<jonas-l>
a promise
<doublec>
rpc.run() can't return anything because it's a behaviour
<doublec>
so it gets passed one
<doublec>
let me modify it to make it clearer
<jonas-l>
not sure why you need a Promise then..
<SeanTAllen>
doublec: you can do fun tag run(): Promise[U32] on Rpc. Check out the Registrar actor in the Bureaucracy package. Not saying you should but you can approach it that way.
<jonas-l>
I imagine you could just provide a callback to be executed on the result
<SeanTAllen>
the nice thing about using a promise rather than a callback is that you can explicitly handle failure/rejection in a clean way. Its a nice way to represent that, whereas a callback isn't. At that point, it really depends on "can this fail".
<doublec>
Right, that's why I'm trying to use a promise vs a callback
<doublec>
So I have a behaviour do_something that puts the result in a Promise[String]
<doublec>
I want to call that but get a U32 as the reslut
<doublec>
so I create a Promise[U32] and and call .next on the Promise[String] and have it do the conversion and fulfill the Promise[U32]
<doublec>
What I want to do is chain the promises
<SeanTAllen>
Yes.
<SeanTAllen>
I think the simplified example is obscuring what you are trying to do. It is at least for me. Whats the use case?
<doublec>
I'm doing an HTTP request that returns JSON
<doublec>
It does this by Fulfulling promise with the JSON
<doublec>
I want a field of that JSON. So I though't I'd chain two promises - the one that gets the JSON, followed by one that extracts the field.
<doublec>
sylvanc: I wanted to factor out the conversion to U32
<doublec>
sylvanc: so callers didn't need to do it all the time
<doublec>
I had to change to an object literal there because I couldn't do a "recover lambda ref(...) => ..." to iso
<sylvanc>
ah, because the lambda has no captures, so it is generated as a primitive
<doublec>
right
<sylvanc>
interesting, seems like the compiler should allow that
<doublec>
I'm wrapping the bitcoin RPC api. The I have a general function that returns the JSON from the different calls and specific wrappers that do the conversion by chaining the promises.
<doublec>
I think that last paste looks like a good approach
<doublec>
dealing with JsonDoc (or any tree structure) where you want to extract parts of the tree and send to another actor really teaches you about capabilties
<doublec>
and shows me how easy it is to accidentally send data owned by something else if the typesystem didn't stop me
aturley has joined #ponylang
aturley has quit [Ping timeout: 244 seconds]
<doublec>
Now I almost want some syntactic sugar that converts "be foo(.., Promise[A])" to be wrapped as "fun tag foo(...) let p=Promise[A]; foo(..., p); p"
<doublec>
Oz worked something like that. A procedure called foo(A, B, C) called be called as C = foo(A, B)
TwoNotes has joined #ponylang
<TwoNotes>
I am looking for a flow-control mechanism in TCPConnection and not finding it. I want to avoid overwhelming the _pending mechnism when sending long files.
<TwoNotes>
This would be in support of "Chunked transfer" under HTTP
<TwoNotes>
It looks like TCPConnection is aware of when the OS can accept more data to write, but this fact is not communicated back to the Notifier
<TwoNotes>
Otherwise, if I was sending a 10MB MP3 file, I would end up sucking all 10MB into memory, stored in the _pending buffer. This seems wasteful
<TwoNotes>
Should I file an Issue, or is there some way to do this I am missing?
copy` has joined #ponylang
aturley has joined #ponylang
Matthias247 has quit [Read error: Connection reset by peer]
aturley has quit [Ping timeout: 260 seconds]
<doublec>
this is weird. I parse a json string. I then do a json.string() and print it, it's the same as what's parsed. I pass the json object to a behaviour and print it and it's corrupted.
<doublec>
I raised issue 801 for the json parsing problem
<jemc>
sylvanc, doublec: that issue is part of the usability problems I've found with lambdas
<jemc>
that is, the compiler should treat them sort of like it treats numeric literals, where it knows what the type *must be*, and it evaluates whether the given lambda *can be* that type
<jemc>
this applies to both the cap of the lambda object and the cap of the apply method
<jemc>
the interface for a lambda consists of both, and mismatches can make that interface unusable
<doublec>
that would remove the 'end end' ugliness when having to use recover to make them iso too
<jemc>
yes, totally, I hate that
<jemc>
andymcn was saying this is just a special case of auto-recover, but that's not quite true
<jemc>
as you've just found sometimes recover doesn't cut it
<jemc>
because you can't recover a val to an iso, for example
<jemc>
I reopened the ticket with this example, because it was closed in favor of the auto-recover ticket
<jemc>
I think some extra compiler smarts for lambdas is still in order, even when we have auto-recover
<jemc>
TwoNotes: should probably file an issue about it for discussion
SilverKey has joined #ponylang
<jemc>
I also don't know of a way to do what you're asking, but it's an important concern from a backpressure perspective
<jemc>
I know sylvanc has spent some time thinking about backpressure and he may have some ideas for this already
lispmeister has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 260 seconds]
amclain has joined #ponylang
<sylvanc>
doublec: this is looking like a compiler bug, i'm working on it now
<sylvanc>
thanks for the report and the test case!
<sylvanc>
jemc: good call on reopening
<sylvanc>
TwoNotes: yes, right now there isn't a backpressure mechanism in TCPConnection
<sylvanc>
there's some runtime stuff that will happen for backpressure
<sylvanc>
but i think also TCPNotify should probably get informed when writing is saturated
gsteed has joined #ponylang
<jemc>
yeah, me too
<jemc>
it's not clear to me how that would get communicated back to the actor calling write/writev though
<jemc>
(well, nevermind, it's super clear - just with a message :P)
<jemc>
but that wouldn't be standardizable though
graaff has quit [Quit: Leaving]
<jemc>
that is, its specific to your custom notifier object and user actor
jemc has quit [Ping timeout: 252 seconds]
tm-exa has quit [Quit: Computer has gone to sleep]
<TwoNotes>
I was thinking a 'drained' callback that would let the Notifier know that the _pending buffer has been emptied. My Notifiers usually have a reference to the parent actor by which I can tell it of such events.
<TwoNotes>
A streaming server tpically fetches some chunksize from a big file (say 20KB) and send that, then would wait for this 'drained' event to send the next chunk.
<TwoNotes>
Chunked transfer is used any time the payload has unknown size (such as rows fetched form a database) or is very big
<TwoNotes>
I am porting some code from Erlang that uses the "cowboy" web server, and it has support for this mode.
rurban has joined #ponylang
aturley has joined #ponylang
_andre has quit [Quit: leaving]
ifraixedes has joined #ponylang
lispmeister has quit [Quit: My Mac has gone to sleep. ZZZzzz…]
draynium has quit [Remote host closed the connection]
<TwoNotes>
Thecomment "When you need a reference table to determine behaviours, the game is lost."
<TwoNotes>
I think this can be taken as a criticism of the early documentation, rather of the basic principle.
SilverKey has joined #ponylang
aturley has joined #ponylang
aturley has quit [Ping timeout: 276 seconds]
<mcguire>
I just submitted issue #802 on setting the terminal for stdin to raw mode. Feel free to ignore it or just close it, it's minor. But I found it confusing.
<mcguire>
"Apparently, they threw a lot of "cool features" into the language without reasoning about orthogonalityand without caring to write the language specification.Also, they guarantee deadlock-freedom by using channels with unbounded buffers..."
<mcguire>
Ouch. On the other hand, that's one thing you can say about Go: no one threw a lot of features into it. :-) But that unbounded buffer thing is going to be a problem.