-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathAbstractOssClient.ts
More file actions
27 lines (27 loc) · 1.01 KB
/
AbstractOssClient.ts
File metadata and controls
27 lines (27 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/**
* Abstract OSS client for dependency injection.
*
* To enable OSS uploads in TracingService, implement this class in your application
* and register it with Tegg IoC. The implementation class MUST be named `OssClient`
* (or use `@SingletonProto({ name: 'ossClient' })`) so the container can resolve it.
*
* @example
* ```typescript
* import { SingletonProto } from '@eggjs/core-decorator';
* import { AccessLevel } from '@eggjs/tegg-types';
* import { AbstractOssClient } from '@eggjs/agent-tracing';
*
* // Class name must be OssClient (registers as 'ossClient' in the IoC container)
* @SingletonProto({ accessLevel: AccessLevel.PUBLIC })
* export class OssClient extends AbstractOssClient {
* async put(key: string, content: string | Buffer): Promise<void> {
* // your OSS implementation here
* }
* }
* ```
*
* If no implementation is registered, OSS uploads are silently skipped.
*/
export abstract class AbstractOssClient {
abstract put(key: string, content: string | Buffer): Promise<void>;
}