Skip to content

Commit 6709467

Browse files
authored
Update docs for root namespace (#1101)
* Attempted fix; not sure why some things aren't showing up * Update docs; pull params namespace * Don't try to use bulleted list in field comments; they don't render * Yank @beta tags; run formatter * PR feedback
1 parent c5a0fb5 commit 6709467

File tree

3 files changed

+60
-81
lines changed

3 files changed

+60
-81
lines changed

src/v2/core.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ export interface TriggerAnnotation {
5656
/**
5757
* A CloudEventBase is the base of a cross-platform format for encoding a serverless event.
5858
* More information can be found in https://github.com/cloudevents/spec
59+
* @typeParam T - The type of the event data.
60+
* @beta
5961
*/
6062
export interface CloudEvent<T> {
6163
/** Version of the CloudEvents spec for this event. */
@@ -80,12 +82,28 @@ export interface CloudEvent<T> {
8082
data: T;
8183
}
8284

83-
/** A handler for CloudEvents. */
85+
/**
86+
* A handler for CloudEvents.
87+
* @typeParam EventType - The kind of event this function handles.
88+
* Always a subclass of CloudEvent<>
89+
* @beta
90+
*/
8491
export interface CloudFunction<EventType extends CloudEvent<unknown>> {
8592
(raw: CloudEvent<unknown>): any | Promise<any>;
8693

94+
/** @alpha */
8795
__trigger?: unknown;
96+
/** @alpha */
8897
__endpoint: ManifestEndpoint;
8998

99+
/**
100+
* The callback passed to the CloudFunction constructor.
101+
* Use run to test a CloudFunction
102+
* @param event - The parsed event to handle.
103+
* @returns Any return value. Google Cloud Functions awaits any promise
104+
* before shutting down your function. Resolved return values
105+
* are only used for unit testing purposes.
106+
* @beta
107+
*/
90108
run(event: EventType): any | Promise<any>;
91109
}

src/v2/index.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
// SOFTWARE.
2222

2323
import * as logger from '../logger';
24-
import * as params from './params';
2524
import * as alerts from './providers/alerts';
2625
import * as eventarc from './providers/eventarc';
2726
import * as https from './providers/https';
@@ -30,18 +29,16 @@ import * as pubsub from './providers/pubsub';
3029
import * as storage from './providers/storage';
3130
import * as tasks from './providers/tasks';
3231

33-
export {
34-
alerts,
35-
https,
36-
identity,
37-
pubsub,
38-
storage,
39-
logger,
40-
params,
41-
tasks,
42-
eventarc,
43-
};
32+
export { alerts, https, identity, pubsub, storage, logger, tasks, eventarc };
4433

45-
export { setGlobalOptions, GlobalOptions } from './options';
34+
export {
35+
setGlobalOptions,
36+
GlobalOptions,
37+
SupportedRegion,
38+
MemoryOption,
39+
VpcEgressSetting,
40+
IngressSetting,
41+
EventHandlerOptions,
42+
} from './options';
4643

4744
export { CloudFunction, CloudEvent } from './core';

src/v2/options.ts

Lines changed: 31 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,55 +36,28 @@ import { HttpsOptions } from './providers/https';
3636
/**
3737
* List of all regions supported by Cloud Functions v2
3838
*/
39-
export const SUPPORTED_REGIONS = [
40-
'asia-northeast1',
41-
'europe-north1',
42-
'europe-west1',
43-
'europe-west4',
44-
'us-central1',
45-
'us-east1',
46-
'us-west1',
47-
] as const;
48-
49-
/**
50-
* A region known to be supported by CloudFunctions v2
51-
*/
52-
export type SupportedRegion = typeof SUPPORTED_REGIONS[number];
53-
54-
/**
55-
* Cloud Functions v2 min timeout value.
56-
*/
57-
export const MIN_TIMEOUT_SECONDS = 1;
58-
59-
/**
60-
* Cloud Functions v2 max timeout value for event handlers.
61-
*/
62-
export const MAX_EVENT_TIMEOUT_SECONDS = 540;
63-
64-
/**
65-
* Cloud Functions v2 max timeout for HTTPS functions.
66-
*/
67-
export const MAX_HTTPS_TIMEOUT_SECONDS = 36_000;
68-
69-
/**
70-
* Maximum number of requests to serve on a single instance.
71-
*/
72-
export const MAX_CONCURRENCY = 1_000;
39+
export type SupportedRegion =
40+
| 'asia-northeast1'
41+
| 'europe-north1'
42+
| 'europe-west1'
43+
| 'europe-west4'
44+
| 'us-central1'
45+
| 'us-east1'
46+
| 'us-west1';
7347

7448
/**
7549
* List of available memory options supported by Cloud Functions.
7650
*/
77-
export const SUPPORTED_MEMORY_OPTIONS = [
78-
'128MiB',
79-
'256MiB',
80-
'512MiB',
81-
'1GiB',
82-
'2GiB',
83-
'4GiB',
84-
'8GiB',
85-
'16GiB',
86-
'32GiB',
87-
] as const;
51+
export type MemoryOption =
52+
| '128MiB'
53+
| '256MiB'
54+
| '512MiB'
55+
| '1GiB'
56+
| '2GiB'
57+
| '4GiB'
58+
| '8GiB'
59+
| '16GiB'
60+
| '32GiB';
8861

8962
const MemoryOptionToMB: Record<MemoryOption, number> = {
9063
'128MiB': 128,
@@ -98,34 +71,18 @@ const MemoryOptionToMB: Record<MemoryOption, number> = {
9871
'32GiB': 32768,
9972
};
10073

101-
/**
102-
* A supported memory option.
103-
*/
104-
export type MemoryOption = typeof SUPPORTED_MEMORY_OPTIONS[number];
105-
10674
/**
10775
* List of available options for VpcConnectorEgressSettings.
10876
*/
109-
export const SUPPORTED_VPC_EGRESS_SETTINGS = [
110-
'PRIVATE_RANGES_ONLY',
111-
'ALL_TRAFFIC',
112-
] as const;
113-
114-
/**
115-
* A valid VPC Egress setting.
116-
*/
117-
export type VpcEgressSetting = typeof SUPPORTED_VPC_EGRESS_SETTINGS[number];
77+
export type VpcEgressSetting = 'PRIVATE_RANGES_ONLY' | 'ALL_TRAFFIC';
11878

11979
/**
12080
* List of available options for IngressSettings.
12181
*/
122-
export const SUPPORTED_INGRESS_SETTINGS = [
123-
'ALLOW_ALL',
124-
'ALLOW_INTERNAL_ONLY',
125-
'ALLOW_INTERNAL_AND_GCLB',
126-
] as const;
127-
128-
export type IngressSetting = typeof SUPPORTED_INGRESS_SETTINGS[number];
82+
export type IngressSetting =
83+
| 'ALLOW_ALL'
84+
| 'ALLOW_INTERNAL_ONLY'
85+
| 'ALLOW_INTERNAL_AND_GCLB';
12986

13087
/**
13188
* GlobalOptions are options that can be set across an entire project.
@@ -148,6 +105,11 @@ export interface GlobalOptions {
148105
* Timeout for the function in sections, possible values are 0 to 540.
149106
* HTTPS functions can specify a higher timeout.
150107
* A value of null restores the default of 60s
108+
* The minimum timeout for a gen 2 function is 1s. The maximum timeout for a
109+
* function depends on the type of function: Event handling functions have a
110+
* maximum timeout of 540s (9 minutes). HTTPS and callable functions have a
111+
* maximum timeout of 36,00s (1 hour). Task queue functions have a maximum
112+
* timeout of 1,800s (30 minutes)
151113
*/
152114
timeoutSeconds?: number | null;
153115

@@ -170,6 +132,7 @@ export interface GlobalOptions {
170132
* Can only be applied to functions running on Cloud Functions v2.
171133
* A value of null restores the default concurrency (80 when CPU >= 1, 1 otherwise).
172134
* Concurrency cannot be set to any value other than 1 if `cpu` is less than 1.
135+
* The maximum value for concurrency is 1,000.
173136
*/
174137
concurrency?: number | null;
175138

@@ -246,7 +209,7 @@ export function getGlobalOptions(): GlobalOptions {
246209
}
247210

248211
/**
249-
* Options that can be set on an individual event-handling Cloud Function.
212+
* Additional fields that can be set on any event-handling Cloud Function.
250213
*/
251214
export interface EventHandlerOptions extends GlobalOptions {
252215
retry?: boolean;
@@ -361,6 +324,7 @@ export function optionsToEndpoint(
361324

362325
/**
363326
* @hidden
327+
* @alpha
364328
*/
365329
export function __getSpec(): {
366330
globalOptions: GlobalOptions;

0 commit comments

Comments
 (0)