import { GrpcClientLookup } from './grpc-util'; /** * Options for the Kalix user function. * * @public */ export interface KalixOptions { /** * The name of this service. * * @defaultValue Defaults to name from `package.json` */ serviceName?: string; /** * The version of this service. * * @defaultValue Defaults to version from `package.json` */ serviceVersion?: string; /** * Path to a Protobuf FileDescriptor set, as output by protoc `--descriptor_set_out=somefile.desc`. * This file must contain all of the component services that this Kalix service serves. * See the `compile-descriptor` command for creating this file. * * @defaultValue `"user-function.desc"` */ descriptorSetPath?: string; /** * Delay completing discovery until proxyPort has been set by the testkit. */ delayDiscoveryUntilProxyPortSet?: boolean; /** * Channel settings. */ channelSettings?: ChannelSettings; } /** * Service binding with address and port. * * @public */ export interface ServiceBinding { /** * The address to bind the Kalix service to. */ address?: string; /** * The port to bind the Kalix service to. */ port?: number; } /** * Entity passivation strategy. * * @public */ export interface EntityPassivationStrategy { /** * Passivation timeout (in milliseconds). */ timeout?: number; } /** * Replicated write consistency setting for replicated entities. * * @public */ export declare enum ReplicatedWriteConsistency { /** * Updates will only be written to the local replica immediately, and then asynchronously * distributed to other replicas in the background. */ LOCAL = 0, /** * Updates will be written immediately to a majority of replicas, and then asynchronously * distributed to remaining replicas in the background. */ MAJORITY = 1, /** * Updates will be written immediately to all replicas. */ ALL = 2 } /** * Options for a {@link Component}. * * @public */ export interface ComponentOptions { /** * The entity type name for all entities of this type. */ entityType?: string; /** * The directories to include when looking up imported protobuf files. * * @defaultValue Defaults to the current directory `['.']` */ includeDirs?: Array; /** * Request headers to be forwarded as metadata to the component. * * @defaultValue Empty `[]` */ forwardHeaders?: Array; } /** * Options for an {@link Entity}. * * @public */ export interface EntityOptions extends ComponentOptions { /** * Entity passivation strategy to use. */ entityPassivationStrategy?: EntityPassivationStrategy; replicatedWriteConsistency?: ReplicatedWriteConsistency; } /** * Kalix Component. * * @public */ export interface Component { /** * The gRPC service name for this component. */ serviceName: string; /** * The protobuf Service for this component. */ service: protobuf.Service; /** * Options for this component. */ options: ComponentOptions | EntityOptions; /** * Access to gRPC clients (with promisified unary methods). */ clients?: GrpcClientLookup; /** * Lookup a protobuf message type. * * This is provided as a convenience to lookup protobuf message types. * * @param messageType - The fully qualified name of the type to lookup * @returns The protobuf message type */ lookupType(messageType: string): protobuf.Type; } /** * Bootstrap parameters to component preStart, internal * * @public */ export interface PreStartSettings { proxyHostname: string; proxyPort: number; } /** * Settings for the gRPC channel used to communicate with the Kalix proxy * * @public */ export interface ChannelSettings { /** * The maximum number of bytes a gRPC message may be when receiving */ maxReceiveMessageLength?: number; /** * The maximum number of bytes a gRPC message may be when sending */ maxSendMessageLength?: number; } /** * Kalix Entity. * * @public */ export interface Entity extends Component { } /** * Kalix service. * * @param options - the options for starting the service * * @public */ export declare class Kalix { private address; private port; private delayDiscoveryUntilProxyPortSet; private proxyPort?; discoveryCompleted: boolean; private descriptorSetPath; private service; private packageInfo; private components; private proto; private server; private runtime; private protocolMajorVersion; private protocolMinorVersion; private docLink; private proxySeen; private proxyHasTerminated; private waitingForProxyTermination; private devMode; constructor(options?: KalixOptions); /** * Set the port that the proxy is running on, for calls from the SDK to the proxy. * Used by the testkit. * @param port */ setProxyPort(port: number): void; /** * Add one or more components to this Kalix service. * * @param components - the components to add * @returns this Kalix service */ addComponent(...components: Array): Kalix; getComponents(): Component[]; private afterStart; /** * Start the Kalix service. * * @param binding - optional address/port binding to start the service on * @returns a Promise of the bound port for this service */ start(binding?: ServiceBinding): Promise; private createDiscoveryHandlers; /** * Shut down the Kalix service. */ shutdown(): void; /** * Shut down the Kalix service. * * @param callback - shutdown callback, accepting possible error */ tryShutdown(callback: (error?: Error) => void): void; private isVersionProbe; private channelSettingsToGrpcChannelOptions; private proxyTerminatedLogic; }