storacha / w3infra

🏗️ Infra for the w3up UCAN protocol implementation
Other
17 stars 7 forks source link

How to find the space when a user PUTs a CAR #95

Open olizilla opened 1 year ago

olizilla commented 1 year ago

We will want to be able to show when a store/add is pending vs we have actually got the CAR.

The store/add dynamo table is currently partitioned by space DID, and the car CID is the sort key, so we enforce a unique car per space. This makes it cheap to find all cars for a space and terrible for finding a space by car CID.

We need some way to connect the ObjectCreated event we get from S3 back to the store/add invocation that enabled it.

Of note, we will need to handle the case where multiple independent store/add invocations are made for the same shard cid. We only skip providing a presigned url once an upload is fully written to s3. multiple callers could start writing at the same time.

olizilla commented 1 year ago

The proposal that @Gozala re-shared is to write the store/add invocation to a bucket prefixed with the car cid like /${carCid}/${invocationCid}... so when we get an S3 ObjectCreated event we can go and list all the keys that start with the carCID to find the 1 or more invocations that got it there.

Alternatives are

olizilla commented 1 year ago

or we could add global secondary index on the the store/add table to let us find spaces by car.

{ partitionKey: 'link', sortKey: 'space' }