4.1.2 • Published 7 months ago

@qiwi/nestjs-enterprise-thrift v4.1.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@qiwi/nestjs-enterprise-thrift"

Nestjs module for working with Apache Thrift

Installation

Requires following packages to be installed

yarn add @qiwi/nestjs-enterprise-thrift

Configuration

Imports

import { Module } from '@nestjs/common'
import { ConnectionProviderModule } from '@qiwi/nestjs-enterprise-connection-provider'
import { LoggerModule } from '@qiwi/nestjs-enterprise-logger-nestjs'
import { ConsulModule } from '@qiwi/nestjs-enterprise-consul-nestjs'
import { ConfigModule } from '@qiwi/nestjs-enterprise-config-nestjs'
import { ThriftModule } from '@qiwi/nestjs-enterprise-thrift'

@Module({
  imports: [
    ConfigModule,
    LoggerModule,
    ConsulModule,
    ConnectionProviderModule,
    // and so on
  ],
  controllers: [],
  providers: [],
})
export class AppModule {}

Usage

@Injectable()
class AuthService {
  client?: Client
  creds?: TCredentials
  token?: TAuthentication

  @Inject('IConfigService')
  config: IConfig

  @Inject('IThriftClientService')
  thrift: IThriftClientService

    getClient() {
        const serviceProfile: IServiceDeclaration = this.config.get('serviceName')
        this.client = this.thrift.getClient(serviceProfile, Client, {
            multiplexer: false,
            connectionOpts: {
                transport: thrift.TBufferedTransport,
                protocol: thrift.TBinaryProtocol,
            },
        })
        return this.client
  }
}

Decorators

@ThriftServer

    @ThriftServer(CalculatorProcessor, 9091)
    class TestServer {
      ping(result: () => void) {
        result()
      }

      add(n1: any, n2: any, result: (arg0: null, arg1: any) => void) {
        result(null, n1 + n2)
      }
    }

Config

{
  "data": {
    "services": {
      "service-1": {
        "type": "thrift",
        "thriftServiceName": "test service 1",
        "discovery": {
          "type": "endpoint",
          "endpoints": [{ "host": "service-1.test.com", "port": "8080" }]
        }
      },
      "service-2": {
        "type": "thrift",
        "thriftServiceName": "test service 2",
        "discovery": {
          "type": "consul",
          "serviceName": "consul name"
        },
        "creds": {
          "type": "username-and-password",
          "username": "username",
          "password": "password"
        }
      }
    }
  }
}

API

Class ConnectionProviderModule

Exports IThriftClientService with token IThriftClientService

Docs

3.0.1

8 months ago

3.0.0

9 months ago

4.1.0

7 months ago

4.0.1

8 months ago

4.0.0

8 months ago

2.1.13

12 months ago

4.1.2

7 months ago

4.0.3

8 months ago

4.1.1

7 months ago

4.0.2

8 months ago

2.1.12

12 months ago

2.1.10

1 year ago

2.1.11

1 year ago

2.1.9

1 year ago

2.1.6

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

1.3.1

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.5

2 years ago

2.1.0

2 years ago

2.0.0

2 years ago

1.3.0

2 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.1

3 years ago

1.2.0

3 years ago

1.1.0

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago