Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: release #73

Merged
merged 5 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/cart/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "ES2019",
"module": "commonjs",
"moduleResolution": "node",
"declaration": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/facade/tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../node_modules/@restorecommerce/dev/tsconfig.json",
"extends": "../dev/tsconfig.json",
"compilerOptions": {
"paths": {
"@modules": ["src/modules/index"],
Expand Down
1 change: 1 addition & 0 deletions packages/grpc-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"lodash": "^4.17.21",
"nice-grpc": "^2.1.7",
"nice-grpc-client-middleware-deadline": "^2.0.10",
"nice-grpc-client-middleware-retry": "^3.1.7",
"protobufjs": "^7.2.6",
"retry": "^0.13.1",
"rxjs": "^7.8.1",
Expand Down
17 changes: 16 additions & 1 deletion packages/grpc-client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
createClientFactory as createClientFactoryInternal,
DefaultCallOptions,
createChannel,
ClientError,
} from 'nice-grpc';
import { CompatServiceDefinition, NormalizedServiceDefinition } from 'nice-grpc/lib/service-definitions';
import {
Expand All @@ -15,6 +16,7 @@ import {
} from './middleware';
import { createLogger } from '@restorecommerce/logger';
import { deadlineMiddleware } from 'nice-grpc-client-middleware-deadline';
import { retryMiddleware } from 'nice-grpc-client-middleware-retry';

export interface GrpcClientConfig {
logger: ReturnType<typeof createLogger>;
Expand All @@ -31,13 +33,26 @@ export function createClient<Service extends CompatServiceDefinition>(
let factory = createClientFactoryInternal()
.use<WithRequestID>(loggingMiddleware(config.logger, config.omittedFields))
.use<WithRequestID>(tracingMiddleware)
.use<WithRequestID>(metaMiddleware);
.use<WithRequestID>(metaMiddleware)
.use<WithRequestID>(retryMiddleware);

if (config.timeout) {
factory = factory.use(deadlineMiddleware);
factory = factory.use(internalDeadlineMiddleware(config.timeout));
}

if (!defaultCallOptions) {
defaultCallOptions = {};
}
defaultCallOptions = Object.assign(defaultCallOptions, {
'*': {
retryMaxAttempts: 5,
retry: true,
},
onRetryableError(error: ClientError, attempt: number, delayMs: number) {
config.logger.error(`Call failed (${attempt}), retrying in ${delayMs}ms`, { code: error.code, message: error.message, stack: error.stack });
}
});
return factory.create(definition, channel, defaultCallOptions);
}

Expand Down
5 changes: 2 additions & 3 deletions packages/rc-grpc-clients/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
},
"devDependencies": {
"@restorecommerce/dev": "^0.0.9",
"@restorecommerce/protos": "^6.8.0",
"@types/jest": "^29.5.3",
"@types/node": "^20.4.1",
"jest": "^29.6.1",
Expand All @@ -46,8 +45,8 @@
"build:compile": "tsc -p tsconfig.lib.json",
"prepublishOnly": "npm run build",
"generate": "npm-run-all generate:client generate:server",
"generate:client": "protoc --experimental_allow_proto3_optional --ts_proto_opt=stringEnums=true,outputClientImpl=false,env=node,useOptionals=all,initializeFieldsAsUndefined=false,outputJsonMethods=true,outputSchema=true,useExactTypes=false,outputServices=nice-grpc,outputServices=generic-definitions --proto_path=../protos --plugin=../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated ../protos/io/restorecommerce/*.proto ../protos/grpc/health/v1/*.proto ../protos/grpc/reflection/v1alpha/*.proto ../protos/test/*.proto ../protos/echo/*.proto ../protos/google/**/*.proto",
"generate:server": "protoc --experimental_allow_proto3_optional --ts_proto_opt=stringEnums=true,outputClientImpl=false,env=node,useOptionals=all,initializeFieldsAsUndefined=false,outputJsonMethods=true,outputSchema=true,useExactTypes=false,outputServices=nice-grpc,outputServices=generic-definitions,snakeToCamel=false --proto_path=../protos --plugin=../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated-server ../protos/io/restorecommerce/*.proto ../protos/grpc/health/v1/*.proto ../protos/grpc/reflection/v1alpha/*.proto ../protos/test/*.proto ../protos/echo/*.proto ../protos/google/**/*.proto",
"generate:client": "protoc --experimental_allow_proto3_optional --ts_proto_opt=stringEnums=true,outputClientImpl=false,env=node,useOptionals=all,initializeFieldsAsUndefined=false,outputJsonMethods=true,outputSchema=true,useExactTypes=false,outputServices=nice-grpc,outputServices=generic-definitions --proto_path=../protos --plugin=../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated ../protos/**/*.proto ../protos/**/**/*.proto ../protos/**/**/**/*.proto",
"generate:server": "protoc --experimental_allow_proto3_optional --ts_proto_opt=stringEnums=true,outputClientImpl=false,env=node,useOptionals=all,initializeFieldsAsUndefined=false,outputJsonMethods=true,outputSchema=true,useExactTypes=false,outputServices=nice-grpc,outputServices=generic-definitions,snakeToCamel=false --proto_path=../protos --plugin=../../node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./src/generated-server ../protos/**/*.proto ../protos/**/**/*.proto ../protos/**/**/**/*.proto",
"test": "jest",
"pretest": "run-s prebuild"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/rc-grpc-clients/tsconfig-base.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../node_modules/@restorecommerce/dev/tsconfig.json",
"extends": "../dev/tsconfig.json",
"compilerOptions": {
"esModuleInterop": false,
"allowSyntheticDefaultImports": true,
Expand Down
7 changes: 6 additions & 1 deletion packages/scs-jobs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,12 @@ export const runWorker = async (queue: string, concurrency: number, cfg: any, lo
worker.on('error', err => logger.error(`worker#${queue} error`, err));
worker.on('closed', () => logger.verbose(`worker#${queue} closed`));
worker.on('progress', (j, p) => logger.debug(`worker#${queue} job#${j.id} progress`, p));
worker.on('failed', (j, err) => logger.error(`worker#${queue} job#${j.id} failed`, err));
worker.on('failed', async (j, err) => {
logger.error(`worker#${queue} job#${j.id} failed`, err);
await jobEvents.emit('jobFailed', { id: j.id, schedule_type: j.data.schedule_type, error: err.message, type: j.name }).catch(err => {
logger.error(`Error emitting jobFailed event for ${j.name}`, err);
});
});
worker.on('closing', msg => logger.verbose(`worker#${queue} closing: ${msg}`));
worker.on('completed', j => logger.info(`worker#${queue} job#${j.id} completed`));
worker.on('stalled', j => logger.warn(`worker#${queue} job#${j} stalled`));
Expand Down
Loading