Skip to content

add better support for ports: open_port, port_command, & others? #89

@mjsir911

Description

@mjsir911

open_port/2

port_command/2 / port_command/3

and a probably better-formed receive for ffi purposes, my understanding is currently process.receive does no type validation and you have to hope that it matches the shape you're expecting, which is fine when it's only used for inter-gleam RPC but I'm trying to represent these pieces of data erlang's open_port might send:

{Port, {data, Data}}
{Port, {exit_status, Status}}
{Port, eof}
{Port, closed}

{Port, {data, {eol | noeol, Line}}} ???

and maybe others. it's kind of hard to find docs for what open_port subprocesses send back up. going off of https://runebook.dev/en/docs/erlang/doc/reference_manual/ports "Messages Received From a Port" a bit.

and, to be clear, these are very representable in gleam. They just require a decode.run() step on an arbitrary piece of data returned by receive, which it's not doing right now and the Subject(Type) api implies an amount of safety that doesn't exist right now. I guess Subject(Dynamic) is what I want?

semi-related to #28, specifically regarding:

As far as the shape of that solution, I'm not really sure. It feels like there should be an "escape hatch" (even if you have to write some Erlang) for when you want to receive some non-Gleam messages with potentially any shape, but still take advantage of Actors and Subjects. Maybe this is possible already and I just haven't figured it out yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions