#DNS lookups in Gleam

1 messages · Page 1 of 1 (latest)

vapid hearth
#

Is there a de facto library in Gleam for performing DNS lookups? If not, I'd be interested in building a library supporting both Erlang and Node targets

I imagine it'd use Erlang's inet_res module and Node's DNS module for the respective targets

wary breach
#

Not that I'm aware of

#

You'd need to have one library for Erlang and another for JS as they have different concurrency systems

vapid hearth
#

I was thinking this library would be synchronous, at least the Erlang inet_res API is synchronous. And then I'd handle any promises directly in JS and return the result directly from the external function

wary breach
#

It's impossible to unwrap a promise

#

That's the function colouring problem

vapid hearth
#

Gotcha thanks been awhile since I developed JavaScript

#

Funny enough it looks like Node's DNS API is callback-based, no promises as far as I can tell

wary breach
#

Same problem

#

There's no way to take a computation that happens later and return it now without a promise or a callback or some other wrapper

#

Not without blocking the event loop, which is likely a bad idea for most applications, and rarely there's an API that makes it possible to do

vapid hearth
#

that makes sense thank you! Relatedly - now that I know we need separate libraries - would it make sense eventually for this DNS resolution functionality to live in gleam_erlang and gleam_javascript, as gleam/erlang/inet_res and gleam/javascript/dns modules respectively?

#

If they're gonna be separate libraries they may as well be direct wrappers , no?

wary breach
#

Those libraries are for common platform specific functionality that many programs will need

#

This isn't common or specifically about JS or Erlang, so they wouldn't be in those libraries

vapid hearth
#

understood

#

is there a naming convention for libraries wrapping a standard module in one of the targets, that doesn't fall under the gleam_erlang or gleam_javascript umbrellas? I'm interested in implementing this and want to comply with standards, if any

wary breach
#

Nope

#

Just nothing that sounds official

robust coral
#

I'm keen in using these wrappers if one gets made, I'll be a JS user.

vapid hearth
#

I think I'm gonna make the erlang one first, only b/c I'm more familiar with that runtime. Willing to collab on a JS lib though!

robust coral
#

erlang first is great. I'm keen to see the API you get too and happy to collab on the JS

zenith dew
#

one thing to keep in mind is that currently bun doesn’t implement node’s dgram module, so getting at udp packets will be impossible. also any web api focused runtime will be challenging (or not possible) for udp support

but node, deno & erlang should be no problem to support

implementing DNS over HTTPS should be no problem anywhere.