Skip to content

Conversation

@gabivlj
Copy link
Contributor

@gabivlj gabivlj commented Jan 20, 2026

When the user calls setEgressTcp, they will be saying "I want all TCP requests to this IP port to be sent to this WorkerEntrypoint".

For now, this feature is marked as 'experimental' as we test it out while its getting released.

The docker client just adds it to a local map of 'address mappings' and calls method to exchange the token for a subrequest channel. It does not really do much.

I used Claude Opus to generate some of this code with some guidance, and ofc reviewed by me.

@codspeed-hq

This comment was marked as outdated.

@gabivlj gabivlj force-pushed the gv/set-egress-binding branch 7 times, most recently from bf34f06 to 608a51b Compare January 21, 2026 00:50
@gabivlj gabivlj changed the title Gv/set egress binding containers: Be able to send channel tokens to a container service Jan 21, 2026
@gabivlj gabivlj marked this pull request as ready for review January 21, 2026 16:34
@gabivlj gabivlj requested review from a team as code owners January 21, 2026 16:34
@gabivlj gabivlj force-pushed the gv/set-egress-binding branch from 608a51b to 68718cb Compare January 21, 2026 16:35
@gabivlj gabivlj requested review from a team and kentonv January 21, 2026 16:37
egressMappings.upsert(kj::mv(addr), kj::mv(subrequestChannel),
[](auto& existing, auto&& newValue) { existing = kj::mv(newValue); });

// TODO: At some point we need to figure out how to make it so
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to fully implement this for local testing now. If it's not available in local testing then nobody will be able to code against this feature.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Responding to both comments about local dev here (@danlapid):

  1. I agree for the feature local dev shouldn't feel like an after-thought.
  2. That's the intent of the experimental flag, I think we can experiment the feature on our end and see if it's working as intended, and iterate on both production and local dev in the meantime.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you had local dev support you could iterate super fast 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Independently of local-dev support being a must for this feature to be publicly available, I think it's not really equivalent the path of connectivity to workers in local dev and in prod.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really see the benefit of rushing to prod before implementing local dev.

It's not really in doubt whether or not it will work in prod. But it'll be hard to write code to test it in prod if we don't also have local dev.

egressMappings.upsert(kj::mv(addr), kj::mv(subrequestChannel),
[](auto& existing, auto&& newValue) { existing = kj::mv(newValue); });

// TODO: At some point we need to figure out how to make it so
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this should be left as "at some point".
Local dev can't be an afterthought.

void signal(jsg::Lock& js, int signo);
jsg::Ref<Fetcher> getTcpPort(jsg::Lock& js, int port);
jsg::Promise<void> setInactivityTimeout(jsg::Lock& js, int64_t durationMs);
void setEgressTcp(jsg::Lock& js, kj::String addr, jsg::Ref<Fetcher> binding);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, should we call this API setEgressHttp() considering that we're going to interpret it as HTTP?

In the future when we support connect handlers then we could actually have an option to support raw TCP, but it would have to be a separate method since we need the app to tell us whether to try parsing the input as HTTP or not.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another method name idea: interceptOutboundHttp

Copy link
Contributor Author

@gabivlj gabivlj Jan 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea. We could also instead have it be at a 'domain'/'hostname' level instead of IP port.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants