Skip to content

Commit c5eebd6

Browse files
feat: set rate config when starting Observatory OpenId monitoring (#216)
* feat: set rate config when starting Observatory OpenId monitoring * fix: bigint
1 parent 7f421f1 commit c5eebd6

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

cli/src/services/server/observatory.services.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export const toggleOpenIdMonitoring = async ({
1313

1414
switch (action) {
1515
case 'start': {
16+
await updateRateConfig({context});
1617
await startOpenIdMonitoring({context});
1718
return;
1819
}
@@ -25,6 +26,25 @@ export const toggleOpenIdMonitoring = async ({
2526
}
2627
};
2728

29+
const updateRateConfig = async ({context}: {context: CliContext}) => {
30+
const {agent} = context;
31+
32+
const {update_rate_config} = await getObservatoryActor({
33+
agent,
34+
canisterId: OBSERVATORY_CANISTER_ID
35+
});
36+
37+
await update_rate_config(
38+
{OpenIdCertificateRequests: null},
39+
{
40+
max_tokens: 300n, // allow up to 300 requests
41+
time_per_token_ns: 200_000_000n // 0.2s per token -> 300/min
42+
}
43+
);
44+
45+
console.log('Rate config applied! ✅');
46+
};
47+
2848
const startOpenIdMonitoring = async ({context}: {context: CliContext}) => {
2949
const {agent} = context;
3050

0 commit comments

Comments
 (0)