Skip to content

Commit 127030c

Browse files
committed
refactor(): Rename GraphileWorkerService to WorkerService
1 parent 5a76ca9 commit 127030c

File tree

7 files changed

+23
-40
lines changed

7 files changed

+23
-40
lines changed

README.md

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Why you should prefer Graphile Worker instead of [Bull](https://github.com/nestj
1515
## Features
1616

1717
- use a `GraphileWorkerModule` to register Graphile Worker with a `asRootAsync` to pass dynamic parameters
18-
- provide a `GraphileWorkerService` to add jobs or start runner
18+
- provide a `WorkerService` to add jobs or start runner
1919
- provide a `OnWorkerEvenet` decorator to add custom behavior on `job:success` for example
2020

2121
## Installation
@@ -82,15 +82,15 @@ export class AppModule {}
8282

8383
## Create jobs
8484

85-
You may use `GraphileWorkerService`:
85+
You may use `WorkerService`:
8686

8787
```ts
88-
import { GraphileWorkerService } from '@app/graphile-worker';
88+
import { WorkerService } from '@app/graphile-worker';
8989
import { Controller, HttpCode, Post } from '@nestjs/common';
9090

9191
@Controller()
9292
export class AppController {
93-
constructor(private readonly graphileWorker: GraphileWorkerService) {}
93+
constructor(private readonly graphileWorker: WorkerService) {}
9494

9595
@Post()
9696
@HttpCode(201)
@@ -114,16 +114,16 @@ export class AppController {
114114

115115
## Start runner
116116

117-
Add `GraphileWorkerService.run` in `main.ts` file:
117+
Add `WorkerService.run` in `main.ts` file:
118118

119119
```ts
120-
import { GraphileWorkerService } from '@app/graphile-worker';
120+
import { WorkerService } from '@app/graphile-worker';
121121
import { NestFactory } from '@nestjs/core';
122122
import { AppModule } from './app.module';
123123

124124
async function bootstrap() {
125125
const app = await NestFactory.create(AppModule);
126-
app.get(GraphileWorkerService).run();
126+
app.get(WorkerService).run();
127127
await app.listen(3000);
128128
}
129129
bootstrap();
@@ -170,12 +170,6 @@ $ npm run test:cov
170170

171171
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
172172

173-
## Stay in touch
174-
175-
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
176-
- Website - [https://nestjs.com](https://nestjs.com/)
177-
- Twitter - [@nestframework](https://twitter.com/nestframework)
178-
179173
## License
180174

181175
Nest is [MIT licensed](LICENSE).

src/graphile-worker.module.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,32 +4,32 @@ import {
44
GraphileWorkerAsyncConfiguration,
55
GraphileWorkerConfigurationFactory,
66
RunnerOptionWithoutEvents,
7-
} from './interfaces/config.interface';
7+
} from './interfaces/module-config.interfaces';
88
import {
99
ConfigurationService,
1010
CONFIGURATION_SERVICE_KEY,
1111
} from './services/configuration.service';
12-
import { GraphileWorkerService } from './services/graphile-worker.service';
1312
import { ListenerExplorerService } from './services/listener-explorer.service';
1413
import { MetadataAccessorService } from './services/metadata-accessor.service';
14+
import { WorkerService } from './services/worker.service';
1515

1616
export const GRAPHILE_WORKER_TOKEN = Symbol.for('NestJsGraphileWorker');
1717

1818
const internalsProviders = [
1919
MetadataAccessorService,
2020
ListenerExplorerService,
21-
GraphileWorkerService,
21+
WorkerService,
2222
];
2323

2424
const internalsModules = [DiscoveryModule];
2525

2626
@Module({
27-
providers: [GraphileWorkerService],
28-
exports: [GraphileWorkerService],
27+
providers: [WorkerService],
28+
exports: [WorkerService],
2929
})
3030
export class GraphileWorkerModule {
3131
/**
32-
* Registers a globally available `GraphileWorkerService`.
32+
* Registers a globally available `WorkerService`.
3333
*
3434
* Example:
3535
*
@@ -55,12 +55,12 @@ export class GraphileWorkerModule {
5555
imports: internalsModules,
5656
module: GraphileWorkerModule,
5757
providers: [graphileConfigurationServiceProvider, ...internalsProviders],
58-
exports: [GraphileWorkerService],
58+
exports: [WorkerService],
5959
};
6060
}
6161

6262
/**
63-
* Registers a globally available `GraphileWorkerService`.
63+
* Registers a globally available `WorkerService`.
6464
*
6565
* Example:
6666
*

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
export * from './decorators/worker-hooks.decorators';
22
export * from './graphile-worker.module';
3-
export * from './services/graphile-worker.service';
3+
export * from './services/worker.service';

src/interfaces/config.interface.ts renamed to src/interfaces/module-config.interfaces.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ export interface GraphileWorkerConfigurationFactory {
1111

1212
export interface GraphileWorkerAsyncConfiguration
1313
extends Pick<ModuleMetadata, 'imports'> {
14-
/**
15-
* Existing Provider to be used.
16-
*/
17-
// useExisting?: Type<GraphileWorkerConfigurationFactory>;
18-
19-
/**
20-
* Type (class name) of provider (instance to be registered and injected).
21-
*/
22-
// useClass?: Type<GraphileWorkerConfigurationFactory>;
23-
2414
/**
2515
* Factory function that returns an instance of the provider to be injected.
2616
*/

src/services/configuration.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,4 @@ export class ConfigurationService {
1111
}
1212
}
1313

14-
// TODO: try to remove this ?
1514
export const CONFIGURATION_SERVICE_KEY = Symbol.for(ConfigurationService.name);

src/services/graphile-worker.service.spec.ts renamed to src/services/worker.service.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import {
33
ConfigurationService,
44
CONFIGURATION_SERVICE_KEY,
55
} from './configuration.service';
6-
import { GraphileWorkerService } from './graphile-worker.service';
76
import { ListenerExplorerService } from './listener-explorer.service';
7+
import { WorkerService } from './worker.service';
88

9-
describe(GraphileWorkerService.name, () => {
10-
let service: GraphileWorkerService;
9+
describe(WorkerService.name, () => {
10+
let service: WorkerService;
1111

1212
beforeEach(async () => {
1313
const module: TestingModule = await Test.createTestingModule({
1414
providers: [
15-
GraphileWorkerService,
15+
WorkerService,
1616
{
1717
provide: ListenerExplorerService,
1818
useValue: {
@@ -32,7 +32,7 @@ describe(GraphileWorkerService.name, () => {
3232
],
3333
}).compile();
3434

35-
service = module.get<GraphileWorkerService>(GraphileWorkerService);
35+
service = module.get<WorkerService>(WorkerService);
3636
});
3737

3838
it('should be defined', () => {

src/services/graphile-worker.service.ts renamed to src/services/worker.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import {
1515
import { ListenerExplorerService } from './listener-explorer.service';
1616

1717
@Injectable()
18-
export class GraphileWorkerService {
19-
private readonly logger = new Logger(GraphileWorkerService.name);
18+
export class WorkerService {
19+
private readonly logger = new Logger(WorkerService.name);
2020
private isMigrationDone: boolean;
2121
private readonly options: RunnerOptions;
2222

0 commit comments

Comments
 (0)