Skip to content

Commit

Permalink
Merge pull request #9907 from hicommonwealth/release/v1.7.3-x
Browse files Browse the repository at this point in the history
Release/v1.7.3 x
  • Loading branch information
ilijabojanovic authored Nov 14, 2024
2 parents a8842e6 + ce027ee commit cc87135
Show file tree
Hide file tree
Showing 270 changed files with 5,378 additions and 4,087 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -438,18 +438,11 @@ jobs:
- name: Run EVM Devnet tests
run: pnpm -F commonwealth test-devnet:evm --allowOnly=false

- name: Coveralls parallel
uses: coverallsapp/github-action@v2
with:
flag-name: evm-devnet-test-coverage
parallel: true
files: packages/commonwealth/coverage/lcov.info

report-coverage:
name: Upload Test Coverage Report
runs-on: ubuntu-latest
timeout-minutes: 5
needs: [ commonwealth-evm-tests, commonwealth-unit-tests ]
needs: [ commonwealth-unit-tests ]
if: always()
strategy:
matrix:
Expand Down
102 changes: 1 addition & 101 deletions common_knowledge/Caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,107 +266,7 @@ fn(args){
`key` param of `cacheWrap` function can be a key to either return string, or `key(..args)` which returns either string or {cacheKey, cacheDuration}.
Same arguments as wrapped fn will be passed to custom key generator function.

### Background Task Runner - Pre-fetching/ Refreshing result periodically

**Scenario:** Good candidate to be run in background.

- We don't need to compute this for every user
- Endpoint is not parameterized, we don't need user input to compute the result
- eg. Global Activity - can be fetched periodically on schedule - to always serve seemingly fresh result to user

Using `caheWrap` example from above:
First parameter of `cacheWrap` is boolean, if we want to skip cache lookup and instead want to override result in cache

**Prepare Function to run as background task**
call `cacheWrap` with first parameter as `true`

```js
const wrapFnOverride = cacheDecorator.cacheWrap(
true,
slowGoodCachingCandidateFn,
key,
duration,
CacheNamespaces.Function_Response
);
```

**Start a background task**

- It adds function to run on fixed interval
- It also run it immediately for the first time

```js
daemon.startTask(
'myWrapFnLabel',
async () => await this.wrapFnOverride(...args),
duration
);
```

**Task Signature**
Daemon can only accept function with no param

- basically, args need to be bound in advance
- change your function to format, here `..args` are bound from closure/context from where we call `daemon.startTask`

```
() => wrapOverrideFn(..args)
```

**Daemon Error Handling**
It clears the task automatically in case of failure

**Re-adding Daemon Task**
Re-adding task with same label will cancel the old task & setup new task with same label

**Cancel Task**
Task can be cancelled using same label if required `daemon.cancelTask(label)`

**Constraints**

- Running background task could be resource intensive, currently background task can be repeated with allowed interval of a 60 seconds or over

### Activity - Decorator Helper class

It hides both cache wrap & daemon from user, it declares both:

- cacheWrap
- cacheWrapOverride
- startTask method - by internally calling daemon.startTask

**Sample Usage:**
**Method to Wrap**

```
const getChainStatus = async (models: DB) => {
body....
}
```

**Generate Wrapper**

```
export const getChainActivity = new Activity(
'getChainStatus', //cache label
getChainStatus,//method to wrap
'getChainStatus', //cache key
60 * 5, // 5 minutes ttl
CacheNamespaces.Global_Response //namespace
);
```

**Drop-In Wrapper**

```js
getChainActivity.queryWithCache(models);
```

**Start Daemon Task**

```js
getChainActivity.startTask(models);
```

## Change Log

- 2401031: Modified by Timothee Legros.
- 230428: Authored by Nakul Manchanda.
27 changes: 27 additions & 0 deletions common_knowledge/GitBranching.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,30 @@ Don't rebase your branches as this will increase the risk of merge conflicts.
There’s really no major advantage to rebase other than a cleaner git history.
However, the downsides are higher risk of merge conflicts and conflicts when you
share rebased commits

# Cherry Picking Specific Branches

Let's say you want to merge a specific branch:

https://github.com/hicommonwealth/commonwealth/pull/9689/commits

You can see all the merge commits on master with this command:

```bash
git log --merges --oneline master
```

Now we should have the PR merge that we want (9689) and to compute a patch all
we have to do is diff between the commit on the next line.

```text
5a1d547b77 Merge pull request #9689 from hicommonwealth/9681.israel.incorrect-redirect-from-profile
afeefe9fa7 Merge pull request #9704 from hicommonwealth/kaleemNeslit.9651.tooltip_reverse_state
```

```bash
git diff -r afeefe9fa7 -r 5a1d547b77 > cherrypick.patch
```

This will be the cherrypicked patch file, and you can patch that onto a specific
branch with the patch command.
141 changes: 0 additions & 141 deletions libs/adapters/src/daemon.ts

This file was deleted.

7 changes: 5 additions & 2 deletions libs/adapters/src/trpc/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ export const command = <
* Builds tRPC query GET endpoint
* @param factory query factory
* @param tag query tag used for OpenAPI spec grouping
* @param forceSecure whether to force secure requests for rate-limited external-router
* @param ttlSecs cache response ttl in seconds
* @param options An object with security and caching related configuration
* @param commit output middleware (best effort), mainly used to update statistics
* - `(input,output,ctx) => Promise<Record<string,unknown>> | undefined | void`
* @returns tRPC query procedure
*/
export const query = <
Expand All @@ -108,13 +109,15 @@ export const query = <
forceSecure?: boolean;
ttlSecs?: number;
},
commit?: Commit<Input, Output>,
) => {
const md = factory();
return buildproc({
method: 'GET',
name: factory.name,
md,
tag,
commit,
forceSecure: options?.forceSecure,
}).query(async ({ ctx, input }) => {
try {
Expand Down
Loading

0 comments on commit cc87135

Please sign in to comment.