Skip to content

Commit

Permalink
优化uuid转uint63的实现方式(使用Int对象代替js代码) (#31)
Browse files Browse the repository at this point in the history
* 优化uuid转uint63的实现方式(使用Int对象代替js代码)

* 调整访问上游的session关键字(用于上游连接共享)
  • Loading branch information
wanpf authored Aug 16, 2023
1 parent f151512 commit 1469320
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pjs/http/forward.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
)
),
(
$=>$.muxHTTP(() => __target, () => _muxHttpOptions).to(
$=>$.muxHTTP(() => (__service.name + __target), () => _muxHttpOptions).to(
$=>$.branch(
() => __cert, (
$=>$.use('lib/connect-tls.js')
Expand Down
8 changes: 2 additions & 6 deletions pjs/lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
((
hexChar = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15 },
toInt63 = str => (
(
value = str.split('').reduce((calc, char) => (calc * 16) + hexChar[char], 0),
) => value / 2
)(),
new Int("u64", new Data(str, "hex").toArray()).toString() / 2
),
traceId = () => algo.uuid().substring(0, 18).replaceAll('-', ''),

) => (
{
namespace: (os.env.POD_NAMESPACE || 'default'),
Expand Down
3 changes: 1 addition & 2 deletions pjs/plugins/traffic-mirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
)
),

hexChar = { '0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'a': 10, 'b': 11, 'c': 12, 'd': 13, 'e': 14, 'f': 15 },
randomInt63 = () => (
algo.uuid().substring(0, 18).replaceAll('-', '').split('').reduce((calc, char) => (calc * 16) + hexChar[char], 0) / 2
new Int("u64", new Data(algo.uuid().substring(0, 18).replaceAll('-', ''), "hex").toArray()).toString() / 2
),
samplingRange = fraction => (fraction > 0 ? fraction : 0) * Math.pow(2, 63),
configCache = new algo.Cache(
Expand Down

0 comments on commit 1469320

Please sign in to comment.