API surface explorations #25

Merged
decentral1se merged 2 commits from api-surface-explorations into main 2026-11-08 16:13:24 +00:00
Owner

Description

I'm exploring an API surface for seemingly boilerplate-ish code, context cancellation and error handling. All pretty messy / not satisfactory so far, but going somewhere, I hope 🙃 Inspired by the API wrapper which came off quite nicely in p2panda.NodeBuilder.

Checklist

  • I/we have not used so-called 'AI' to create the proposed changes.
# Description I'm exploring an API surface for seemingly boilerplate-ish code, context cancellation and error handling. All pretty messy / not satisfactory so far, but going somewhere, I hope 🙃 Inspired by the API wrapper which came off quite nicely in [`p2panda.NodeBuilder`](https://git.coopcloud.tech/decentral1se/p2panda-go/src/branch/main/nodebuilder/nodebuilder.go). ## Checklist - [x] I/we have not used so-called 'AI' to create the proposed changes.
@@ -0,0 +10,4 @@
var err error
endpointBuilder := iroh.NewEndpointBuilder()
endpointBuilder.ApplyN0()
Collaborator

since this is following the "options" pattern, i think it's better here if you do endpointBuilder.ApplyMinimal. a later option can then set a more maximal preset. the reason is some situations i do not want to use N0's defaults. this is not just a preference for my own projects but important in other situations, like testing strictly local connectivity :)

since this is following the "options" pattern, i think it's better here if you do [`endpointBuilder.ApplyMinimal`](https://godocs.io/git.coopcloud.tech/decentral1se/iroh-go#EndpointBuilder.ApplyMinimal). a later option can then set a more maximal preset. the reason is some situations i do not want to use N0's defaults. this is not just a preference for my own projects but important in other situations, like testing strictly local connectivity :)
decentral1se marked this conversation as resolved
@@ -0,0 +16,4 @@
if err := iroh.As(err); err != nil {
return endpoint, err
}
endpoint.Online()
Collaborator

beware beware, this endpoint.Online bit can, depending on relay connectivity (I THINK) hang indefinitely

beware beware, this `endpoint.Online` bit can, depending on relay connectivity (I THINK) hang indefinitely
Collaborator

some more thinking, maybe the online wait could be an option?

func WithUntilOnline(){}
some more thinking, maybe the online wait could be an option? ```golang func WithUntilOnline(){} ```
Author
Owner

I think I'll have to leave this to the option API consumer as the options that get passed in are for constructing the endpoint, not running anything on top of it. I guess it gives more control since we don't really know what is coming back out of that function call 😆

I think I'll have to leave this to the option API consumer as the options that get passed in are for constructing the endpoint, not running anything on top of it. I guess it gives more control since we don't really know what is coming back out of that function call 😆
decentral1se marked this conversation as resolved
Collaborator

@decentral1se yuhhhh so excited to see this, and for it to build on your experiences w/ p2panda-go!! i left some comments based on my experience wrangling experiments :>

@decentral1se yuhhhh so excited to see this, and for it to build on your experiences w/ p2panda-go!! i left some comments based on my experience wrangling experiments :>
decentral1se force-pushed api-surface-explorations from 781a17afa1 to 2dd159a87c 2026-11-05 19:13:50 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 2dd159a87c to 157b9699e6 2026-11-05 19:40:09 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 157b9699e6 to 4b020bd112 2026-11-05 20:57:00 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 4b020bd112 to a31a00d4a8 2026-11-05 20:58:09 +00:00 Compare
decentral1se force-pushed api-surface-explorations from a31a00d4a8 to b601ccc2ff 2026-11-05 20:59:28 +00:00 Compare
decentral1se force-pushed api-surface-explorations from b601ccc2ff to 1afa4776a9 2026-11-05 21:07:00 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 504b9872e8 to e123d83960 2026-11-07 13:02:41 +00:00 Compare
decentral1se force-pushed api-surface-explorations from e123d83960 to 36f2413627 2026-11-08 10:02:23 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 36f2413627 to bd011cd157 2026-11-08 12:16:38 +00:00 Compare
decentral1se force-pushed api-surface-explorations from bd011cd157 to 3fa75ca28c 2026-11-08 12:17:23 +00:00 Compare
decentral1se force-pushed api-surface-explorations from 3fa75ca28c to c3a4c52cfe 2026-11-08 14:27:43 +00:00 Compare
decentral1se force-pushed api-surface-explorations from c3a4c52cfe to c1531e9d55 2026-11-08 15:20:51 +00:00 Compare
decentral1se force-pushed api-surface-explorations from c1531e9d55 to e87922bb62 2026-11-08 15:50:37 +00:00 Compare
Author
Owner
Still quite lost as how to cleanly stop streams / connections / endpoints 🤓 * https://docs.rs/iroh/latest/iroh/endpoint/struct.RecvStream.html * https://docs.rs/iroh/latest/iroh/endpoint/struct.SendStream.html * https://www.iroh.computer/blog/closing-a-quic-connection Experiment ongoing 🙃
decentral1se force-pushed api-surface-explorations from e87922bb62 to a260f21903 2026-11-08 16:05:51 +00:00 Compare
decentral1se marked the pull request as ready for review 2026-11-08 16:05:57 +00:00
decentral1se added 1 commit 2026-11-08 16:07:30 +00:00
feat: wip: interfaces, logger, new APIs
continuous-integration/drone/push Build is failing
006c857766
decentral1se force-pushed api-surface-explorations from a260f21903 to 006c857766 2026-11-08 16:07:30 +00:00 Compare
decentral1se added 1 commit 2026-11-08 16:11:34 +00:00
fix: go mod tidy for examples
continuous-integration/drone/push Build is passing
9073d172cc
Author
Owner

I've moved the current experiments into a separate example and will merge. I have a suspicion that the bindings don't support closing up streams/connections/endpoints cleanly and will reproduce some smaller examples shortly update: see below. For now, I'm happy with the direction this is going in: a more high-level API which doesn't get in the way of low-level access.

I've moved the current experiments into a separate example and will merge. ~~I have a suspicion that the bindings don't support closing up streams/connections/endpoints cleanly and will reproduce some smaller examples shortly~~ **update**: see below. For now, I'm happy with the direction this is going in: a more high-level API which doesn't get in the way of low-level access.
decentral1se merged commit fead67fced into main 2026-11-08 16:13:24 +00:00
Author
Owner
Graceful Shutdown Works ™️ * https://git.coopcloud.tech/decentral1se/iroh-go/src/branch/main/examples/cleanclose * https://git.coopcloud.tech/decentral1se/iroh-go/src/branch/main/examples/withcontext
Collaborator

I've moved the current experiments into a separate example and will merge. I have a suspicion that the bindings don't support closing up streams/connections/endpoints cleanly and will reproduce some smaller examples shortly update: see below. For now, I'm happy with the direction this is going in: a more high-level API which doesn't get in the way of low-level access.

cool! I like that framing of your api exploration - higher level function calls that can coexist with more finely-grained / fussy approaches

it has been fun to poke my head in each time you force pushed "ah what change happened now?" ^__^

> I've moved the current experiments into a separate example and will merge. ~~I have a suspicion that the bindings don't support closing up streams/connections/endpoints cleanly and will reproduce some smaller examples shortly~~ **update**: see below. For now, I'm happy with the direction this is going in: a more high-level API which doesn't get in the way of low-level access. cool! I like that framing of your api exploration - higher level function calls that can coexist with more finely-grained / fussy approaches it has been fun to poke my head in each time you force pushed "ah what change happened now?" ^__^
cblgh deleted branch api-surface-explorations 2026-11-10 18:39:38 +00:00
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: decentral1se/iroh-go#25