UNPKG

faastjs

Version:

Serverless batch computing made simple.

100 lines (99 loc) 4.28 kB
import { cloudbilling_v1, cloudfunctions_v1, GoogleApis, pubsub_v1 } from "googleapis"; import { PackerResult } from "../packer"; import { CleanupOptions, CommonOptions, ProviderImpl, UUID } from "../provider"; import { WrapperOptions } from "../wrapper"; import CloudFunctions = cloudfunctions_v1; import PubSubApi = pubsub_v1; import CloudBilling = cloudbilling_v1; /** * Valid Google Cloud * {@link https://cloud.google.com/compute/docs/regions-zones/ | regions}. Only * some of these * {@link https://cloud.google.com/functions/docs/locations | regions have Cloud Functions}. * @public */ export declare type GoogleRegion = "asia-east1" | "asia-east2" | "asia-northeast1" | "asia-south1" | "asia-southeast1" | "australia-southeast1" | "europe-north1" | "europe-west1" | "europe-west2" | "europe-west3" | "europe-west4" | "europe-west6" | "northamerica-northeast1" | "southamerica-east1" | "us-central1" | "us-east1" | "us-east4" | "us-west1" | "us-west2"; /** * Google-specific options for {@link faastGoogle}. * @public */ export interface GoogleOptions extends CommonOptions { /** * The region to create resources in. Garbage collection is also limited to * this region. Default: `"us-central1"`. */ region?: GoogleRegion; /** * Additional options to pass to Google Cloud Function creation. See * {@link https://cloud.google.com/functions/docs/reference/rest/v1/projects.locations.functions#CloudFunction | projects.locations.functions}. * @remarks * If you need specialized options, you can pass them to the Google Cloud * Functions API directly. Note that if you override any settings set by * faast.js, you may cause faast.js to not work: * * ```typescript * const requestBody: CloudFunctions.Schema$CloudFunction = { * name, * entryPoint: "trampoline", * timeout, * availableMemoryMb, * sourceUploadUrl, * runtime: "nodejs14", * ...googleCloudFunctionOptions * }; * ``` * */ googleCloudFunctionOptions?: CloudFunctions.Schema$CloudFunction; /** @internal */ _gcWorker?: (resources: GoogleResources, services: GoogleServices) => Promise<void>; } export interface GoogleResources { trampoline: string; requestQueueTopic?: string; requestSubscription?: string; responseQueueTopic?: string; responseSubscription?: string; region: string; } export interface GoogleCloudPricing { perInvocation: number; perGhzSecond: number; perGbSecond: number; perGbOutboundData: number; perGbPubSub: number; } export declare class GoogleMetrics { outboundBytes: number; pubSubBytes: number; } export interface GoogleServices { readonly cloudFunctions: CloudFunctions.Cloudfunctions; readonly pubsub: PubSubApi.Pubsub; readonly google: GoogleApis; readonly cloudBilling: CloudBilling.Cloudbilling; } /** * @internal */ export interface GoogleState { resources: GoogleResources; services: GoogleServices; url?: string; project: string; functionName: string; metrics: GoogleMetrics; options: Required<GoogleOptions>; gcPromise?: Promise<void>; } export declare function defaultGcWorker(resources: GoogleResources, services: GoogleServices): Promise<void>; export declare const defaults: Required<GoogleOptions>; export declare const GoogleImpl: ProviderImpl<GoogleOptions, GoogleState>; export declare function initializeGoogleServices(): Promise<GoogleServices>; export declare function initialize(fmodule: string, nonce: UUID, options: Required<GoogleOptions>): Promise<GoogleState>; export declare function getResponseQueueTopic(project: string, functionName: string): string; export declare function getResponseSubscription(project: string, functionName: string): string; export declare function getRequestSubscription(project: string, functionName: string, region: string): string; export declare function cleanup(state: GoogleState, options: CleanupOptions): Promise<void>; export declare function googlePacker(functionModule: string, options: CommonOptions, wrapperOptions: WrapperOptions, FunctionName: string): Promise<PackerResult>; export declare function logUrl(state: GoogleState): string;