storacha / w3up

⁂ w3up protocol implementation
https://github.com/storacha-network/specs
Other
57 stars 19 forks source link

Unify UCAN API endpoints #325

Open gobengo opened 1 year ago

gobengo commented 1 year ago

Motivation:

To Do

Problem

Solution

Nice to Have

Decisions

✅ What should the URL be of the unified ucanto endpoint?

Status

Ideas

✅ Should the unified UCAN API endpoint respond to websocket connections?

Status

Context

Problem

Considerations

Solutions Considered

  1. 😅 don't have api-gateway at all....
    • decided on 2023-01-10 with @Gozala
    • just have the unified api endpoint be access-api
      • i.e. add code to access-api/service so the underlying service can handle invocations to upload-api by re-executing them via a client connection over http channel
      • implications
      • also decided: no need in this issue to make upload-api able to handle access-api caps. We will only make it so access-api can handle all caps. (and there will be no api-gateway that can handle all caps, which is what I had started)
  2. api-gateway responds to incoming websocket connections by redirecting to access-api worker
    • pros
      • simple to implement
    • cons
      • doesn't consider what to do for other services.
      • but we can decide that later when we actually have the problem of multiple services that can communicate over websocket
  3. access-client can discover separate access-api websocket url from unified api did document
    • e.g. a service endpoint at #access-api and/or service of type w3protocol.web3.storage/services/access-api
    • ucanto invocations could still go through unified api, but websocket would have to connect to the other URL.
    • pros
      • unified api endpoint is simpler because no websocket logic
      • websocket connection url can still be discovered by following nose from the service DID (DID -> did doc -> services(typ
    • cons
      • access-client needs to know that there are separate URLs for websocket vs ucanto-over-http, which is kinda worse than its status quo of connecting to same access-api URL for both
  4. api-gateway handles incoming websocket connections by proxying to upstream access-api
    • pros
      • fully encapsulates upstream services
      • if we unify the websocket handling protocol, then specific upstream services may not need to implement one directly, and the unified one can aggregate events from across services
    • cons
      • unclear how to generically handle websocket connections (i.e. what protocols do we expect? how do we decide to proxy to access-api vs upload-api et al?)
gobengo commented 1 year ago

this is a little related to https://github.com/web3-storage/w3protocol/issues/182

gobengo commented 1 year ago

status today will address feedback on this PR adding initial functionality: https://github.com/web3-storage/w3protocol/pull/334#pullrequestreview-1244943356

gobengo commented 1 year ago

status you can now issue store/list invocations against access-api

test here. store/add invocations are also proxied ok to upload-api handlers, and currently get a result from this in upload-api

gobengo commented 1 year ago

status I will update it to use new ucanto functionality to do the proxying without issuing a new delegation - https://github.com/web3-storage/w3protocol/issues/383

gobengo commented 1 year ago

status In general after above work, you should be able to issue ucan invocations only against the deployed access-api. If they are store/* or upload/* invocations, they will be proxied to be handled by the upload-api running on aws.

This was the gist of how @Gozala and I decided to do it (especially at the time in January).