Skip to content

Commit

Permalink
feat: debug request metadata (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 committed Aug 30, 2023
1 parent bcbbced commit e32611f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ proto
.fleet
.DS_Store
logs/
package-lock.json
6 changes: 6 additions & 0 deletions src/client/API.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@
* limitations under the License.
*/

import { debuglog } from 'node:util';
import { AsyncLocalStorage } from 'node:async_hooks';
import { Metadata } from '@grpc/grpc-js';
import { KV, RequestWithMeta, Map } from '../types/common';
import { mergeMetadataToMap } from '../utils';

const debug = debuglog('layotto:client:api');

export type CreateMetadataHook = (localStorage?: AsyncLocalStorage<any>) => Record<string, string>;

export interface APIOptions {
Expand Down Expand Up @@ -60,6 +63,9 @@ export class API {
metadata.add(key, moreMetadata[key]);
}
}
if (debug.enabled) {
debug('createMetadata %o', metadata.toHttp2Headers());
}
return metadata;
}

Expand Down

0 comments on commit e32611f

Please sign in to comment.