#glisten/mist: Getting in on the v1 hype train

1 messages ยท Page 1 of 1 (latest)

grand pendant
#

It's come up a bunch in the context of libraries, and I've been a bad semantic versioning citizen. So I figured it was probably time to just go for it.

https://github.com/rawhat/glisten is now officially v1 ๐Ÿฅณ

https://github.com/rawhat/mist is now on its v1 release candidate. Feel free to test it if you want.

Notable changes are relatively minimal, but you can see the CHANGELOGs for details. glisten had a little bit of a glow-up in terms of the public API (mostly just hiding some stuff that didn't need to be public). mist can now do Server-Sent Events, as well as a few smaller things.

Thanks for being awesome everybody lucyglow

GitHub

A pure gleam TCP library. Contribute to rawhat/glisten development by creating an account on GitHub.

GitHub

gleam HTTP server. because it glistens on a web. Contribute to rawhat/mist development by creating an account on GitHub.

marsh nest
#

hype!!!

#

ooooh SSE

grand pendant
#

yeah i'm not sure how solid the interface is for that, but i'm als not sure how/if i can make it better ๐Ÿ˜•

marsh nest
#

Is there an example somewhere?

nova ridge
#

Is this the season where all the gleam libs hit 1.0

#

@vivid totem has been harassing me to release glint as 1.0

grand pendant
marsh nest
#

I don't have any clever ideas

#

A clock perhaps?

grand pendant
#

ah yeah that sounds good

solar dirge
#

a culture of 0.x.y in the ecosystem is quite me

grand pendant
#

classic... ```

So, I've searched around for a solution built into the protocol, and it there does not appear to be one. If your server calls response.emit('close') or response.end(), the client will treat this like an error and attempt to reconnect to the server. (At least in the case of Chrome, it will attempt to reconnect indefinitely, unless it considers the network error fatal).

So it appears that one way or another, your client has to close the connection```

#

but my example works, so i'm gonna just ship it lol

marsh nest
#

That's quite funny

grand pendant
marsh nest
#

It needs to be the same as the websocket API minus the messages from the socket

#

Otherwise you are not going to be able to handle system messages, debugging, etc

#

Anything that is about sending and recieving messages should look like an actor and have actor as a base, unless you wanna implement all the under-the-hood OTP stuff from scratch

grand pendant
#

i'd really like to not have to spawn another process for this, but i might just have to do that

marsh nest
#

Why's that?

grand pendant
#

it's the same issue that i've had with the websocket one (and why i'm also spawning a separate process for that)... the selector types need to be different, and i don't have a way to express that with the actor API

marsh nest
#

No I mean why do you not want to spawn another process?

#

Every long running process needs to implement the OTP system protocol, debugging, etc. Actor gives you that, but this API makes it impossible

grand pendant
#

yes i understand that, i'm gonna change it

marsh nest
#

wicked

grand pendant
#

it seems a bit superfluous to spawn another process when i have the handler... but i guess it's not going to be doing very much, so that's not really a big deal

marsh nest
#

It's like 1ms of latency for something that lives for probably minutes, that's fine

#

I doubt you'd be able to ever measure the difference

grand pendant
#

fair point

#

thanks for the feedback!

marsh nest
#

No, thank you ๐Ÿ’œ

#

Mist rules

grand pendant
grand pendant
#

v1.0.0-rc2 released ๐Ÿฅณ fixed up the SSE implementation! the link above has the details, but it's basically: ```rust
mist.server_sent_events(
req,
response.new(200),
init: fn() {
...
actor.Ready(state, selector)
},
loop: fn(message, conn, state) {
actor.continue(state)
}
)

which i think resolves the issues noted above, and should look as one would expect for something like this ๐Ÿ˜…
marsh nest
#

So what's next on your hit list ๐Ÿ‘€

grand pendant
#

i should probably do the graceful shutdown thing... but i'm also i think reasonably close to http/2? after that... i dunno lol

marsh nest
#

HTTP2 would be incredibly cool

#

Honestly that's probably just about everything at that point?

grand pendant
#

yeah i also can't really think of much else

#

then what do i do doll

marsh nest
#

๐Ÿค”

#

Looking for another ambitious project?

grand pendant
#

haha maybe... everybody here is so good at jumping on cool library ideas

marsh nest
#

Websocket client? ๐Ÿ‘€

grand pendant
#

oh yeah that's a good idea

vivid totem
#

that'd be really great

nova ridge
#

what the gleam http client story like these days

vivid totem
#

gleam_httpc is the go-to

marsh nest
#

httpc is good enough now that it handles TLS nicely

#

When we have big Gleam companies maybe we'll hit some performance stuff that motivates the creation of something else, but until then I think we're good

nova ridge
#

oh when did it get TLS ๐Ÿ˜ฎ

marsh nest
#

OTP26 maybe?

nova ridge
#

ooooo

#

nice okay that'll be my default then

marsh nest
#

Well it always had it but was painful to configure. Now it just works it seems

solar dirge
grand pendant
#

i like gleam

solar dirge
#

Maybe work on gleam then? Just an idea?

#

Whatever excites you, so great you did and are doing mist โค๏ธ

grand pendant
nova ridge
marsh nest
#

I love how @grand pendant just casually drops these super technical projects

grand pendant
#

well i "cheated" a bit since i did most of the work in mist lol

grand pendant
marsh nest
#

โ€œI cheated by implementing it by handโ€ sure ok dude

nova ridge
#

Self-plagiarism

marsh nest
#

Iโ€™m telling hbomb

grand pendant
marsh nest
#

I love that emoji

grand pendant
#

me toooo

#

don't want to annoyingly ping, but dylan (dmmulroy) was working on a twitch client on stream last night, and will need a ws client it seems. so it felt a little serendipitous with the previous mention too lol

#

still needs a bunch of work so idk how soon i'll be able to publish it, but i'm happy with the progress for how long i've spent on it so far

marsh nest
#

Have you told him?

grand pendant
#

it came up in chat, but i also don't want to like block him if i can't get it reasonably functional soon lol

marsh nest
#

that's fair

#

I thought you meant to block his messages on here for a second

#

I was like "wow he always seemed nice to me"

grand pendant
#

this is my super secret chat

marsh nest
#

ok so

#

why is Gleam is quotes? ๐Ÿ˜†

#

is it secretly written in Elixir

flat yarrow
#

Those are back ticks (`) not quotes (" or ')

nova ridge
#

Inline code formattting

marsh nest
#

I think it's secretly Lua

grand pendant
#

i will remove it haha

#

just wanted to squat the name

marsh nest
#

wise

midnight harbor
grand pendant
#

ouch

marsh nest
#

burn

grand pendant
marsh nest
#

Hypeeee

#

Big day!

grand pendant
#

the perf seems to be back to parity with 0.17 so i'm happy with that

marsh nest
#

What was the issue?

#

I guess periodic benchmarking is worthwhile

grand pendant
#

it was the date generation on every request

#

and yeah, that does seem useful

marsh nest
#

So what do you need the date for?

grand pendant
#

it's required by the spec

#

to include that header

marsh nest
#

TIL

grand pendant
#

it has been an enlightening 24 hours lol

solar dirge
#

which soec, websocket or http? latter because of proxies and cache?

solar dirge
#

still not a great hack but confirmed in my intuition ๐Ÿ™‚ at guessing the culprit on bird/system date fetch

marsh nest
#

For the timestamp thing

#

Is it an int that is stored?

#

I was wondering if it might be faster to use atomics than ETS or such

#

storing the atomics ref in persistent term

grand pendant
#

i can try that

#

i'm currently storing the string, but could also just use the timestamp

#

err

#

we'd talked about it, but i'd need to re-implement some stuff, since i'd need to store birl.now() which is a type

marsh nest
#

You don't need to store that record

#

you are not going to use the monotonic clock

#

only the wall clock

grand pendant
#

yes i'm just saying, i'd need to implement the formatting stuff myself in that case

marsh nest
#

Can just vendor that one function

grand pendant
#

i can try it... do you think ETS will be a significant performance impact?

marsh nest
#

Nah

#

It's fast

#

Atomics is faster though

#

Idk if you could measure the difference in the context of Mist

grand pendant
#

yeah, makes sense

#

now that the start app module thing is working, i may just... do that and call it a day

nova ridge
#

are erlang atomics only ever ints? ๐Ÿค”

marsh nest
#

atomics are a CPU feature and they're always numbers yeah

#

oh hmm does the BEAM not expose atomic floats

nova ridge
#

are there any better docs than just the erlang stdlib docs for the atomics module

marsh nest
#

Don't think so

#

What are you after?

nova ridge
marsh nest
#

if you can use atomics use atomics

#

If it's data use ETS

#

if it's behaviour use a process