Stalegood first issue✨ enhancement🎨 sdk
仓库指标
- Star
- (5,385 star)
- PR 合并指标
- (30 天内没有已合并 PR)
描述
Use Case
To visualize the entire state of Counter (https://github.com/winglang/wing/issues/6100), you need to have some way to find out what keys have values stored
Proposed Solution
bring cloud;
let c = new cloud.Counter();
test "obtain counter's keys" {
expect.equal(c.keys() == ["default"]);
c.inc();
expect.equal(c.keys() == ["default"]);
c.inc(1, "my-key");
expect.equal(c.keys() == ["default", "my-key"]);
}
Alternative:
bring cloud;
let c = new cloud.Counter();
test "obtain counter's keys" {
expect.equal(c.entries() == [CounterEntry { key: "default", value: 0 }]);
c.inc();
expect.equal(c.entries() == [CounterEntry { key: "default", value: 1 }]);
c.inc(1, "my-key");
expect.equal(c.entries() == [CounterEntry { key: "default", value: 1 }, CounterEntry { key: "my-key", value: 1 }]);
}
Implementation Notes
For AWS targets which implement Counter using DynamoDB, it might be possible to implement these with the Scan operation
Component
SDK
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
- If this issue is labeled needs-discussion, it means the spec has not been finalized yet. Please reach out on the #dev channel in the Wing Discord.