feat: add plan limit information to plan/get results#150
Conversation
| ### `plan/get` | ||
|
|
||
| Capability can be invoked to get information about the plan that the account is currently signed up for. | ||
| Capability can be invoked to get information about the plan that the account is currently signed up for. The plan name and the storage limit are returned. The plan limit is expressed in bytes. Not to be confused with the storage **included** in the plan. A `0` limit indicates that uploads will not be rejected due to hitting a limit (the plan is effectively "unlimited"), which doesn't mean the customer won't be charged for the extra storage. |
There was a problem hiding this comment.
Optional field that is not present if no limit is set?
There was a problem hiding this comment.
mmm, I don't know. The code implementing this will end up calling planLimit in w3infra and that returns 0 for no limit, so it would require removing it from the response explicitly and is probably not worth it.
There was a problem hiding this comment.
I think it's ok for a function that is explicitly called to get a limit to return 0 to signify no limit, however in the invocation response, sending a value when there is none kinda sucks - it's extra bandwdith for nothing and means that you need to look at the spec to interpret what 0 means. Whereas if there is no limit property when there is no limit makes far more sense to me.
It's also more backward compatible with the existing API to have the field optional - all plans in the hot network currently will not send this property.
This doesn't yet exist in the response, I think simply omiting the property is easy enough, especially in JS.
There was a problem hiding this comment.
ok, ok, but extra bandwidth? It's a request that will be made in response to a human action, i.e. it won't happen at a high rate. And "limit": 0 doesn't look like huge overhead for being explicit.
And we should discuss what more backward compatible means 😄
Anyways, done!
…ult (#645) Ref. storacha/project-tracking#620 Add a `limit` property to `plan/get` successful result definition, as recently added to the spec (storacha/specs#150). It is expressed in bytes, so it has been added as a string because we expect limits higher than 9PiBs in Forge.
Ref. storacha/project-tracking#620 Implements the new `limit` property for `plan/get` successful results, as specified in storacha/specs#150 and defined in storacha/upload-service#645. `limit` is defined as a string to support limits over 9PiB. The result of `planLimit` has been kept as a number because it is used in other parts of the code for arithmetics. Those other call sites will be refactored to use BigInt in a different PR. For now, the result of `planLimit` is converted to string at the API boundary.
the usage service previously defaults to a 5GiB plan limit which is the free storage limit plan on storacha. but everywhere in our background jobs controller for the usage report we'd still have to explicitly pass the pass the plan limit or just hardcode the limit when we upgrade to a large storage capacity, which can be quite the hassle — having to edit the code everytime we upgrade. after a chat with travis, i found out that the `PlanGetSuccess` response from the `plan/get` capability already includes an optional `limit` prop proposed in the [spec: #607](storacha/specs#150)
the usage service previously defaults to a 5GiB plan limit which is the free storage limit plan on storacha. but everywhere in our background jobs controller for the usage report we'd still have to explicitly pass the pass the plan limit or just hardcode the limit when we upgrade to a large storage capacity, which can be quite the hassle — having to edit the code everytime we upgrade. after a chat with travis, i found out that the `PlanGetSuccess` response from the `plan/get` capability already includes an optional `limit` prop proposed in the [spec: #607](storacha/specs#150)
Ref. storacha/project-tracking#620
Currently,
plan/getonly returns the name of the plan a given account is subscribed to. This PR adds information about the storage limit for the account, which makes special sense when using the reserved capacity plan in Storacha Forge.