Skip to content
This repository was archived by the owner on Apr 4, 2025. It is now read-only.
This repository was archived by the owner on Apr 4, 2025. It is now read-only.

Allow Gateway-to-Gateway topology #2

Description

@lukeed

Right now, the link() method that Shard and Gateway must define is somewhat-awkwardly returning a relationships object. Currently, the self property inside of Gateway isn't even used.

However, this is done so that it's a non-breaking change to include Gateway-to-Gateway at a later date. By moving to an object now, that means that developer can opt into this topology by simply adding new keys to the object. The valid Gateway#link return objects will look like this:

type Node<T> = Gateway<T> | Shard<T>;

abstract class Gateway<T> {
  abstract link(bindings: T): {
    self: DurableObjectNamespace & Gateway<T>;
    child: DurableObjectNamespace & Node<T>;
  } | {
    self: DurableObjectNamespace & Gateway<T>;
    child: DurableObjectNamespace & Node<T>;
    parent: DurableObjectNamespace & Gateway<T>;
    gateway: string;
  };
}

Similar to Shard, the Gateway will have to know what it is (self) and what its parent class and parent identifiers are. This is so that Gateways can gossip with one another (use case?) and so that it can forward live-count information to its parent.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions