-
Notifications
You must be signed in to change notification settings - Fork 251
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
178 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,18 +2,20 @@ | |
|
||
swagger-ui from https://github.com/swagger-api/swagger-ui @v5.11.2 | ||
- Created [window-observer.js](./swagger-ui/window-observer.js) to remove `Try it out` functionality for subscription endpoints | ||
- See the latest version [here](https://unpkg.com/browse/[email protected]/) | ||
|
||
```bash | ||
curl https://unpkg.com/swagger-ui-dist@5.11.2/swagger-ui.css > swagger-ui/swagger-ui.css | ||
curl https://unpkg.com/swagger-ui-dist@5.11.2/swagger-ui-bundle.js > swagger-ui/swagger-ui-bundle.js | ||
curl https://unpkg.com/swagger-ui-dist@5.11.2/swagger-ui-standalone-preset.js > swagger-ui/swagger-ui-standalone-preset.js | ||
curl https://unpkg.com/swagger-ui-dist@5.18.2/swagger-ui.css > swagger-ui/swagger-ui.css | ||
curl https://unpkg.com/swagger-ui-dist@5.18.2/swagger-ui-bundle.js > swagger-ui/swagger-ui-bundle.js | ||
curl https://unpkg.com/swagger-ui-dist@5.18.2/swagger-ui-standalone-preset.js > swagger-ui/swagger-ui-standalone-preset.js | ||
``` | ||
|
||
## Stoplight | ||
Spotlight UI from https://github.com/stoplightio/elements @v8.0.3 | ||
Spotlight UI from https://github.com/stoplightio/elements @v8.5.2 | ||
- Created [window-observer.js](./stoplight-ui/window-observer.js) to remove `Send API Request` functionality for subscription endpoints | ||
- See the latest version [here](https://unpkg.com/browse/@stoplight/[email protected]/) | ||
|
||
```bash | ||
curl https://unpkg.com/@stoplight/elements@8.0.3/styles.min.css > stoplight-ui/styles.min.css | ||
curl https://unpkg.com/@stoplight/elements@8.0.3/web-components.min.js > stoplight-ui/web-components.min.js | ||
curl https://unpkg.com/@stoplight/elements@8.5.2/styles.min.css > stoplight-ui/styles.min.css | ||
curl https://unpkg.com/@stoplight/elements@8.5.2/web-components.min.js > stoplight-ui/web-components.min.js | ||
``` |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 The VeChainThor developers | ||
|
||
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
package thor | ||
|
||
import "sync/atomic" | ||
|
||
// CacheStats is a utility for collecting cache hit/miss. | ||
type CacheStats struct { | ||
hit, miss atomic.Int64 | ||
flag atomic.Int32 | ||
} | ||
|
||
// Hit records a hit. | ||
func (cs *CacheStats) Hit() int64 { return cs.hit.Add(1) } | ||
|
||
// Miss records a miss. | ||
func (cs *CacheStats) Miss() int64 { return cs.miss.Add(1) } | ||
|
||
// Stats returns the number of hits and misses and whether | ||
// the hit rate was changed comparing to the last call. | ||
func (cs *CacheStats) Stats() (bool, int64, int64) { | ||
hit := cs.hit.Load() | ||
miss := cs.miss.Load() | ||
lookups := hit + miss | ||
|
||
hitRate := float64(0) | ||
if lookups > 0 { | ||
hitRate = float64(hit) / float64(lookups) | ||
} | ||
flag := int32(hitRate * 1000) | ||
|
||
return cs.flag.Swap(flag) != flag, hit, miss | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 The VeChainThor developers | ||
|
||
// Distributed under the GNU Lesser General Public License v3.0 software license, see the accompanying | ||
// file LICENSE or <https://www.gnu.org/licenses/lgpl-3.0.html> | ||
|
||
package thor | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestCacheStats(t *testing.T) { | ||
cs := &CacheStats{} | ||
cs.Hit() | ||
cs.Miss() | ||
_, hit, miss := cs.Stats() | ||
|
||
assert.Equal(t, int64(1), hit) | ||
assert.Equal(t, int64(1), miss) | ||
|
||
changed, _, _ := cs.Stats() | ||
assert.False(t, changed) | ||
|
||
cs.Hit() | ||
cs.Miss() | ||
assert.Equal(t, int64(3), cs.Hit()) | ||
|
||
changed, hit, miss = cs.Stats() | ||
|
||
assert.Equal(t, int64(3), hit) | ||
assert.Equal(t, int64(2), miss) | ||
assert.True(t, changed) | ||
} |