Skip to content

Commit 1bf0a86

Browse files
authored
Inline eventarc callback type (#1118)
1 parent be7e529 commit 1bf0a86

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/v2/providers/eventarc.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
// SOFTWARE.
2222

23+
/**
24+
* Cloud functions to integrate directly with Eventarc.
25+
* @packageDocumentation
26+
*/
27+
2328
import { convertIfPresent, copyIfPresent } from '../../common/encoding';
2429
import { ManifestEndpoint } from '../../runtime/manifest';
2530
import { CloudEvent, CloudFunction } from '../core';
@@ -147,19 +152,14 @@ export interface EventarcTriggerOptions extends options.EventHandlerOptions {
147152
retry?: boolean;
148153
}
149154

150-
/**
151-
* A function that takes a {@link CloudEvent}.
152-
*/
153-
export type CloudEventHandler = (event: CloudEvent<any>) => any | Promise<any>;
154-
155155
/** Handles an Eventarc event published on the default channel.
156156
* @param eventType - Type of the event to trigger on.
157157
* @param handler - A function to execute when triggered.
158158
* @returns A function that you can export and deploy.
159159
*/
160160
export function onCustomEventPublished<T = any>(
161161
eventType: string,
162-
handler: CloudEventHandler
162+
handler: (event: CloudEvent<T>) => any | Promise<any>
163163
): CloudFunction<CloudEvent<T>>;
164164

165165
/** Handles an Eventarc event.
@@ -169,12 +169,12 @@ export function onCustomEventPublished<T = any>(
169169
*/
170170
export function onCustomEventPublished<T = any>(
171171
opts: EventarcTriggerOptions,
172-
handler: CloudEventHandler
172+
handler: (event: CloudEvent<T>) => any | Promise<any>
173173
): CloudFunction<CloudEvent<T>>;
174174

175175
export function onCustomEventPublished<T = any>(
176176
eventTypeOrOpts: string | EventarcTriggerOptions,
177-
handler: CloudEventHandler
177+
handler: (event: CloudEvent<T>) => any | Promise<any>
178178
): CloudFunction<CloudEvent<T>> {
179179
let opts: EventarcTriggerOptions;
180180
if (typeof eventTypeOrOpts === 'string') {

0 commit comments

Comments
 (0)