GitHub

RDK

Instances

You can create new instances from a class as well as call their methods on existing ones.

  • You cannot call more than 10 getInstances in parallel.

  • You cannot call more than 10 methods in parallel.

  • Nested calls have depth limit. You cannot make nested calls more than 5 levels.

It's dangerous to create loops by nested method calls and make sure you don't call write methods from the same instance.

interface GetInstance {
    httpMethod?: string
    queryStringParams?: Record<string, any>
    headers?: KeyValueString
    body?: any
    classId: string
    instanceId?: string
    lookupKey?: {
        name: string
        value: string
    }
}


interface MethodCall extends GetInstance {
    methodName: string
    retryConfig?: RetryConfig,
}


interface CloudObjectResponse<T = any> {
    statusCode: number
    body?: T
    headers?: KeyValueString
}


interface GetInstanceResponse extends CloudObjectResponse {
    body?: {
        newInstance: boolean
        instanceId: string
        init?: MethodDefinitionCommonModels
        get?: MethodDefinitionCommonModels
        methods: MethodDefinitionSummary[],
        response?: any
    }
}


async function getInstance(input: GetInstance): Promise<GetInstanceResponse | undefined> {
    // ...
}
async function methodCall(input: MethodCall): Promise<CloudObjectResponse | undefined> {
    // ...
}

Usage

import RDK from '@retter/rdk'


const rdk = new RDK()


await rdk.getInstance({ classId: 'TestClass' })
await rdk.methodCall({ classId: 'TestClass', instanceId: 'my-instance-id', methodName: 'sayHello' })


await rdk.pipeline()
    .getInstance({ classId: 'AnotherTestClass' })
    .getInstance({ classId: 'AnotherTestClass', instanceId: 'another-instance-id' })
    .methodCall({ classId: 'AnotherTestClass', instanceId: 'another-instance-id', methodName: 'sayHello' })
    .methodCall({ classId: 'AnotherTestClass', instanceId: 'another-instance-id', methodName: 'sayHello', body: { a: 1 } })
    .send()

API Reference

Get Instance Input

ParameterTypeRequiredDescription
classIdstringtrueClass ID
instanceIdstringfalseInstance ID. You can skip this parameter to create a new instance or to use advantage of getInstanceId delegate method.
lookupKey{ name: string; value: string }falseResolve instance via lookup key
httpMethodstringfalseHTTP method. Default value is POST
queryStringParamsRecord<string, any>falseQuery string parameters
headersRecord<string, string>falseRequest headers
bodyRecord<string, any>falsePayload

Method Call Input

ParameterTypeRequiredDescription
classIdstringtrueClass ID
instanceIdstringfalseInstance ID. You can skip this parameter to create a new instance or to use advantage of getInstanceId delegate method.
lookupKey{ name: string; value: string }falseResolve instance via lookup key
methodNamestringtrueMethod name
httpMethodstringfalseHTTP method. Default value is POST
queryStringParamsRecord<string, any>falseQuery string parameters
headersRecord<string, string>falseRequest headers
bodyRecord<string, any>falsePayload
retryConfig{ delay: number; count: number; rate: number }falseRetry configuration with backoff strategy. The delay parameter is in milliseconds

Get Instance Output

ParameterTypeRequiredDescription
statusCodenumbertrueHTTP status code
headersRecord<string, string>trueResponse headers
body.newInstancebooleantrueFlag to detect whether the instance is newly created or not
body.instanceIdstringtrueInstance id
body.initMethodDefinitionCommonModelsfalseValidation models for init delegate method (constructor)
body.getMethodDefinitionCommonModelsfalseValidation models for get delegate method
body.methodsMethodDefinitionSummary[]falseList of available methods
body.responseRecord<string, any>falseActual response body

Method Call Output

ParameterTypeRequiredDescription
statusCodenumbertrueHTTP status code
headersRecord<string, string>trueResponse headers
bodyRecord<string, any>falseResponse body
Previous
Authentication