Skip to main content
Server Source code Package

GCP Cloud Functions

Google Cloud Functions source for walkerOS. Lightweight runtime adapter with plug-and-play assignment to a Cloud Functions handler, batch processing for multiple events per request, and configurable CORS. The @walkeros/server-source-gcp package also ships sourcePubSubPull and sourcePubSubPush for ingesting from Pub/Sub topics; this page covers the Cloud Functions handler only.

Where this fits

The GCP Cloud Functions source is a server source in the walkerOS flow:

It receives events via HTTP and forwards them to your destinations.

Installation

npm install @walkeros/server-source-gcp @google-cloud/functions-framework
import { sourceCloudFunction } from '@walkeros/server-source-gcp';
import { startFlow } from '@walkeros/collector';
import { http } from '@google-cloud/functions-framework';

const { sources } = await startFlow({
sources: {
  gcp: {
    code: sourceCloudFunction,
    config: {
      settings: { cors: true, batch: true },
    },
  },
},
destinations: {
  // Your destinations
},
});

// Plug-and-play: source.push IS the Cloud Function handler
http('walkerHandler', sources.gcp.push);

Configuration

This source uses the standard source config wrapper (consent, data, env, id, ...). For the shared fields see source configuration. Package-specific fields live under config.settings and are listed below.

Settings

PropertyTypeDescriptionMore
corsboolean | objectCORS configuration: false = disabled, true = allow all origins, object = custom configuration
timeoutintegerRequest timeout in milliseconds (max: 540000 for GCP)

Mapping

This package does not define custom rule-level settings. For the standard rule fields (consent, condition, data, batch, name, policy) see mapping.

Examples

Order POST

A Cloud Function HTTP POST carrying an order payload becomes a walker order complete event.

Event
{
  "method": "POST",
  "body": {
    "event": "order complete",
    "data": {
      "id": "ORD-700",
      "total": 99.99,
      "currency": "EUR"
    }
  },
  "headers": {
    "content-type": "application/json"
  }
}
Out
elb({
  "name": "order complete",
  "data": {
    "id": "ORD-700",
    "total": 99.99,
    "currency": "EUR"
  }
})

POST event

A GCP Cloud Function HTTP POST with a JSON body becomes a single walker elb event.

Event
{
  "method": "POST",
  "body": {
    "event": "page view",
    "data": {
      "title": "Home",
      "url": "https://example.com/"
    }
  },
  "headers": {
    "content-type": "application/json"
  }
}
Out
elb({
  "name": "page view",
  "data": {
    "title": "Home",
    "url": "https://example.com/"
  }
})

Request format

Single event

{
"event": "page view",
"data": {
  "title": "Home Page",
  "path": "/"
}
}

Batch events

{
"events": [
  { "event": "page view", "data": { "title": "Page 1" } },
  { "event": "button click", "data": { "id": "btn1" } }
]
}

Ingest metadata

Extract request metadata and forward it through the pipeline.

config.ingest must use the map operator. Keys are output field names; values are direct field paths on the request scope (no req. prefix). A bare object like { ip: 'ip' } is silently inert: without the map operator the source passes the whole request through and no field is extracted.

const { sources } = await startFlow({
sources: {
  gcp: {
    code: sourceCloudFunction,
    config: {
      settings: { cors: true },
      ingest: {
        map: {
          ip: { key: 'ip' },
          ua: { key: 'headers.user-agent' },
          origin: { key: 'headers.origin' },
        },
      },
    },
  },
},
});

Available ingest paths

PathDescription
ipClient IP address
headers.*HTTP headers (user-agent, origin, etc.)
methodHTTP method
hostnameRequest hostname

Pub/Sub

The same @walkeros/server-source-gcp package also exports sourcePubSubPull (streaming pull subscriber) and sourcePubSubPush (HTTP webhook handler) for ingesting events from a Pub/Sub topic. See the Pub/Sub source page for full settings, lifecycle, decoders, OIDC verification, and setup reference.

💡 Need implementation support?
elbwalker offers hands-on support: setup review, measurement planning, destination mapping, and live troubleshooting. Book a 2-hour session (€399)