Skip to content

Commit ca0a566

Browse files
Health Check Improvements (#254)
1 parent c672380 commit ca0a566

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+945
-206
lines changed

.changeset/bright-gifts-turn.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
---
2+
'@powersync/service-core': minor
3+
---
4+
5+
- Added `ServiceContextMode` to `ServiceContext`. This conveys the mode in which the PowerSync service was started in.
6+
- `RouterEngine` is now always present on `ServiceContext`. The router will only configure actual servers, when started, if routes have been registered.
7+
- Added typecasting to `!env` YAML custom tag function. YAML config environment variable substitution now supports casting string environment variables to `number` and `boolean` types.
8+
9+
```yaml
10+
replication:
11+
connections: []
12+
13+
storage:
14+
type: mongodb
15+
16+
api:
17+
parameters:
18+
max_buckets_per_connection: !env PS_MAX_BUCKETS::number
19+
20+
healthcheck:
21+
probes:
22+
use_http: !env PS_MONGO_HEALTHCHECK::boolean
23+
```

.changeset/khaki-cows-thank.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
'@powersync/service-image': minor
3+
---
4+
5+
- Added typecasting to `!env` YAML custom tag function. YAML config environment variable substitution now supports casting string environment variables to `number` and `boolean` types.
6+
7+
```yaml
8+
replication:
9+
connections: []
10+
11+
storage:
12+
type: mongodb
13+
14+
api:
15+
parameters:
16+
max_buckets_per_connection: !env PS_MAX_BUCKETS::number
17+
18+
healthcheck:
19+
probes:
20+
use_http: !env PS_MONGO_HEALTHCHECK::boolean
21+
```
22+
23+
- Added the ability to customize healthcheck probe exposure in the configuration. Backwards compatibility is maintained if no `healthcheck->probes` config is provided.
24+
25+
```yaml
26+
healthcheck:
27+
probes:
28+
# Health status can be accessed by reading files (previously always enabled)
29+
use_filesystem: true
30+
# Health status can be accessed via HTTP requests (previously enabled for API and UNIFIED service modes)
31+
use_http: true
32+
```

.changeset/little-pianos-fetch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/service-types': minor
3+
---
4+
5+
Added healthcheck types to PowerSyncConfig

.changeset/shaggy-bikes-relax.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/lib-services-framework': minor
3+
---
4+
5+
Switched default health check probe mechanism from filesystem to in-memory implementation. Consumers now need to manually opt-in to filesystem probes.

.changeset/thick-wolves-invent.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@powersync/service-module-core': minor
3+
---
4+
5+
Initial core module release. This moves RouterEngine API route registrations, health check probe configuration and metrics configuration from the service runners to this shared module.

libs/lib-services/src/container.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
1+
import { ServiceAssertionError } from '@powersync/service-errors';
12
import _ from 'lodash';
23
import { ErrorReporter } from './alerts/definitions.js';
34
import { NoOpReporter } from './alerts/no-op-reporter.js';
45
import { MigrationManager } from './migrations/MigrationManager.js';
5-
import { ProbeModule, TerminationHandler, createFSProbe, createTerminationHandler } from './signals/signals-index.js';
6-
import { ServiceAssertionError } from '@powersync/service-errors';
6+
import {
7+
ProbeModule,
8+
TerminationHandler,
9+
createInMemoryProbe,
10+
createTerminationHandler
11+
} from './signals/signals-index.js';
712

813
export enum ContainerImplementation {
914
REPORTER = 'reporter',
@@ -45,7 +50,7 @@ export type ServiceIdentifier<T = unknown> = string | symbol | Newable<T> | Abst
4550

4651
const DEFAULT_GENERATORS: ContainerImplementationDefaultGenerators = {
4752
[ContainerImplementation.REPORTER]: () => NoOpReporter,
48-
[ContainerImplementation.PROBES]: () => createFSProbe(),
53+
[ContainerImplementation.PROBES]: () => createInMemoryProbe(),
4954
[ContainerImplementation.TERMINATION_HANDLER]: () => createTerminationHandler(),
5055
[ContainerImplementation.MIGRATION_MANAGER]: () => new MigrationManager()
5156
};

modules/module-core/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @powersync/service-module-core

modules/module-core/LICENSE

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Functional Source License, Version 1.1, Apache 2.0 Future License
2+
3+
## Abbreviation
4+
5+
FSL-1.1-Apache-2.0
6+
7+
## Notice
8+
9+
Copyright 2023-2024 Journey Mobile, Inc.
10+
11+
## Terms and Conditions
12+
13+
### Licensor ("We")
14+
15+
The party offering the Software under these Terms and Conditions.
16+
17+
### The Software
18+
19+
The "Software" is each version of the software that we make available under these Terms and Conditions, as indicated by our inclusion of these Terms and Conditions with the Software.
20+
21+
### License Grant
22+
23+
Subject to your compliance with this License Grant and the Patents, Redistribution and Trademark clauses below, we hereby grant you the right to use, copy, modify, create derivative works, publicly perform, publicly display and redistribute the Software for any Permitted Purpose identified below.
24+
25+
### Permitted Purpose
26+
27+
A Permitted Purpose is any purpose other than a Competing Use. A Competing Use means making the Software available to others in a commercial product or service that:
28+
29+
1. substitutes for the Software;
30+
2. substitutes for any other product or service we offer using the Software that exists as of the date we make the Software available; or
31+
3. offers the same or substantially similar functionality as the Software.
32+
33+
Permitted Purposes specifically include using the Software:
34+
35+
1. for your internal use and access;
36+
2. for non-commercial education;
37+
3. for non-commercial research; and
38+
4. in connection with professional services that you provide to a licensee using the Software in accordance with these Terms and Conditions.
39+
40+
### Patents
41+
42+
To the extent your use for a Permitted Purpose would necessarily infringe our patents, the license grant above includes a license under our patents. If you make a claim against any party that the Software infringes or contributes to the infringement of any patent, then your patent license to the Software ends immediately.
43+
44+
### Redistribution
45+
46+
The Terms and Conditions apply to all copies, modifications and derivatives of the Software.
47+
If you redistribute any copies, modifications or derivatives of the Software, you must include a copy of or a link to these Terms and Conditions and not remove any copyright notices provided in or with the Software.
48+
49+
### Disclaimer
50+
51+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
52+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
53+
54+
### Trademarks
55+
56+
Except for displaying the License Details and identifying us as the origin of the Software, you have no right under these Terms and Conditions to use our trademarks, trade names, service marks or product names.
57+
58+
## Grant of Future License
59+
60+
We hereby irrevocably grant you an additional license to use the Software under the Apache License, Version 2.0 that is effective on the second anniversary of the date we make the Software available. On or after that date, you may use the Software under the Apache License, Version 2.0, in which case the following will apply:
61+
62+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
63+
You may obtain a copy of the License at
64+
65+
http://www.apache.org/licenses/LICENSE-2.0
66+
67+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

modules/module-core/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# PowerSync Service Module Core
2+
3+
Module which registers and configures basic core functionality for PowerSync services.

modules/module-core/package.json

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"name": "@powersync/service-module-core",
3+
"repository": "https://github.com/powersync-ja/powersync-service",
4+
"types": "dist/index.d.ts",
5+
"version": "0.0.0",
6+
"main": "dist/index.js",
7+
"license": "FSL-1.1-Apache-2.0",
8+
"type": "module",
9+
"publishConfig": {
10+
"access": "public"
11+
},
12+
"scripts": {
13+
"build": "tsc -b",
14+
"build:tests": "tsc -b test/tsconfig.json",
15+
"clean": "rm -rf ./dist && tsc -b --clean",
16+
"test": "vitest"
17+
},
18+
"exports": {
19+
".": {
20+
"import": "./dist/index.js",
21+
"require": "./dist/index.js",
22+
"default": "./dist/index.js"
23+
},
24+
"./types": {
25+
"import": "./dist/types/types.js",
26+
"require": "./dist/types/types.js",
27+
"default": "./dist/types/types.js"
28+
}
29+
},
30+
"dependencies": {
31+
"@powersync/lib-services-framework": "workspace:*",
32+
"@powersync/service-core": "workspace:*",
33+
"@powersync/service-rsocket-router": "workspace:*",
34+
"@powersync/service-types": "workspace:*",
35+
"fastify": "4.23.2",
36+
"@fastify/cors": "8.4.1"
37+
},
38+
"devDependencies": {}
39+
}

0 commit comments

Comments
 (0)