@walkeros/server-source-gcp 0.4.2 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -8
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -9,6 +9,25 @@ runtime adapters for GCP services.
|
|
|
9
9
|
npm install @walkeros/server-source-gcp @google-cloud/functions-framework
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
import {
|
|
16
|
+
sourceCloudFunction,
|
|
17
|
+
type SourceCloudFunction,
|
|
18
|
+
} from '@walkeros/server-source-gcp';
|
|
19
|
+
import { startFlow } from '@walkeros/collector';
|
|
20
|
+
import { http } from '@google-cloud/functions-framework';
|
|
21
|
+
|
|
22
|
+
const { elb } = await startFlow<SourceCloudFunction.Push>({
|
|
23
|
+
sources: { api: { code: sourceCloudFunction } },
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
http('walkerHandler', elb);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
12
31
|
## Cloud Functions Source
|
|
13
32
|
|
|
14
33
|
The Cloud Functions source provides an HTTP handler that receives walker events
|
|
@@ -17,17 +36,39 @@ and forwards them to the walkerOS collector.
|
|
|
17
36
|
### Basic Usage
|
|
18
37
|
|
|
19
38
|
```typescript
|
|
20
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
sourceCloudFunction,
|
|
41
|
+
type SourceCloudFunction,
|
|
42
|
+
} from '@walkeros/server-source-gcp';
|
|
43
|
+
import { startFlow } from '@walkeros/collector';
|
|
21
44
|
import { http } from '@google-cloud/functions-framework';
|
|
22
45
|
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
);
|
|
46
|
+
// Handler singleton - reused across warm invocations
|
|
47
|
+
let handler: SourceCloudFunction.Push;
|
|
48
|
+
|
|
49
|
+
async function setup() {
|
|
50
|
+
if (handler) return handler;
|
|
51
|
+
|
|
52
|
+
const { elb } = await startFlow<SourceCloudFunction.Push>({
|
|
53
|
+
sources: {
|
|
54
|
+
api: {
|
|
55
|
+
code: sourceCloudFunction,
|
|
56
|
+
config: {
|
|
57
|
+
settings: { cors: true },
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
destinations: {
|
|
62
|
+
// Your destinations
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
handler = elb;
|
|
67
|
+
return handler;
|
|
68
|
+
}
|
|
28
69
|
|
|
29
|
-
//
|
|
30
|
-
http('walkerHandler',
|
|
70
|
+
// Register with Cloud Functions framework
|
|
71
|
+
setup().then((h) => http('walkerHandler', h));
|
|
31
72
|
```
|
|
32
73
|
|
|
33
74
|
## Bundler Integration
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@walkeros/server-source-gcp",
|
|
3
3
|
"description": "Google Cloud Platform server sources for walkerOS (Cloud Functions)",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.5.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"module": "./dist/index.mjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"update": "npx npm-check-updates -u && npm update"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@walkeros/core": "0.
|
|
21
|
+
"@walkeros/core": "0.5.0"
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@google-cloud/functions-framework": "^3.0.0"
|