Skip to content

Commit d0292e8

Browse files
authored
add readme info (#84)
1 parent 0e37af0 commit d0292e8

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed

samples/broken-links-ok/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Overview
2+
3+
This sample uses the `@google-cloud/synthetics-sdk-broken-links` to create a Google Cloud Function that can be used with Google Cloud Monitoring Synthetics.
4+
5+
## Installation
6+
7+
```
8+
# from root of repo, build all packages
9+
npm install
10+
```
11+
12+
Update the `options` variable in the `index.js` to the desired `origin_uri` along with any other (optional) fields.
13+
14+
## Running
15+
16+
The following command runs this sample locally
17+
```
18+
npx functions-framework --target=BrokenLinkChecker
19+
```
20+
21+
The following command deploys this sample to gcp as a cloud function.
22+
```
23+
gcloud functions deploy broken-links-http --gen2 --runtime=nodejs18 --region=us-east4 --source=. --entry-point=BrokenLinkChecker --trigger-http --timeout=60 --memory=2048M
24+
```
25+
26+
## Running Local Synthetics SDK Changes
27+
28+
Use the following instructions to run the version of the synthetics-sdk-broken-links package that has local changes. *The instructions should start from the root directory for the `synthetics-sdk` workspace.*
29+
30+
1. Pack "@google-cloud/synthetics-sdk-api" into tar file, output to synthetics-sdk-broken-links
31+
```
32+
npm pack --workspace="@google-cloud/synthetics-sdk-api" --pack-destination=packages/synthetics-sdk-broken-links/
33+
cd packages/synthetics-sdk-broken-links/
34+
```
35+
36+
2. Open package.json, update synthetics-sdk-broken-links dependency for "@google-cloud/synthetics-sdk-api" to use tar file.
37+
38+
```
39+
"dependencies": {
40+
...
41+
"@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz"
42+
...
43+
}
44+
```
45+
46+
3. Go back to root directory of synthetics-sdk
47+
```
48+
cd ../..
49+
```
50+
51+
4. Pack all workspace packages into tar files, output to samples/broken-links-ok
52+
```
53+
npm pack --workspaces --pack-destination=samples/broken-links-ok/
54+
cd samples/broken-links-ok/
55+
```
56+
57+
5. Open package.json, update broken-links-ok dependency for "@google-cloud/synthetics-sdk-broken-links" and "@google-cloud/synthetics-sdk-api" to use tar file.
58+
```
59+
"dependencies": {
60+
...
61+
"@google-cloud/synthetics-sdk-broken-links": "google-cloud-synthetics-sdk-broken-links-0.1.2.tgz",
62+
"@google-cloud/synthetics-sdk-api": "google-cloud-synthetics-sdk-api-0.5.0.tgz"
63+
...
64+
}
65+
```
66+
67+
Proceed back to steps in [RUNNING](#Running)

samples/broken-links-ok/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15+
// [START monitoring_synthetic_monitoring_broken_links_invocation]
16+
1517
const functions = require('@google-cloud/functions-framework');
1618
const GcmSynthetics = require('@google-cloud/synthetics-sdk-broken-links');
1719

@@ -40,3 +42,5 @@ const options = {
4042
};
4143

4244
functions.http('BrokenLinkChecker', GcmSynthetics.runBrokenLinksHandler(options));
45+
46+
// [END monitoring_synthetic_monitoring_broken_links_invocation]

0 commit comments

Comments
 (0)