@dbx-tools/cli-falkor-db 0.9.43
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/LICENSE +202 -0
- package/README.md +92 -0
- package/bin/dbx-falkor-db.ts +5 -0
- package/index.ts +12 -0
- package/lib/bin/dbx-falkor-db.d.ts +2 -0
- package/lib/bin/dbx-falkor-db.js +4 -0
- package/lib/index.d.ts +8 -0
- package/lib/index.js +10 -0
- package/lib/src/cli.d.ts +17 -0
- package/lib/src/cli.js +27 -0
- package/lib/src/options.d.ts +31 -0
- package/lib/src/options.js +42 -0
- package/lib/src/runtime.d.ts +12 -0
- package/lib/src/runtime.js +84 -0
- package/lib/tsconfig.tsbuildinfo +1 -0
- package/package.json +99 -0
- package/src/cli.ts +42 -0
- package/src/options.ts +53 -0
- package/src/runtime.ts +94 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# `@dbx-tools/cli-falkor-db`
|
|
2
|
+
|
|
3
|
+
Run an embedded FalkorDB database in the foreground with its active graph on
|
|
4
|
+
local disk. Redis creates RDB snapshots only after configured writes, and the
|
|
5
|
+
CLI can stream completed snapshots to a Databricks Unity Catalog Volume.
|
|
6
|
+
|
|
7
|
+
## Start A Local Database
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
dbx falkor-db --data-dir /tmp/my-app/falkordb
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The standalone `dbx-falkor-db` executable accepts the same options. FalkorDB
|
|
14
|
+
uses a private Unix socket and does not expose a TCP Redis port. Keep the command
|
|
15
|
+
running for as long as the application needs the database.
|
|
16
|
+
|
|
17
|
+
Without `--volume`, `dump.rdb` remains in the local data directory and completed
|
|
18
|
+
snapshot activity is logged. This is useful for local development and for
|
|
19
|
+
verifying persistence behavior before durable storage is configured.
|
|
20
|
+
|
|
21
|
+
## Back Up To A Databricks Volume
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
dbx falkor-db \
|
|
25
|
+
--data-dir /tmp/my-app/falkordb \
|
|
26
|
+
--volume /Volumes/main/app_data/state/falkordb \
|
|
27
|
+
--profile WORKSPACE \
|
|
28
|
+
--snapshot-seconds 300 \
|
|
29
|
+
--snapshot-min-changes 1 \
|
|
30
|
+
--retention 5
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
The selected profile is used only for Volume access. On startup the CLI restores
|
|
34
|
+
and verifies `latest.json` before starting FalkorDB. During operation it uploads
|
|
35
|
+
immutable snapshots first, then advances the manifest. Upload failures are
|
|
36
|
+
logged while the local graph continues running.
|
|
37
|
+
|
|
38
|
+
## Shutdown Behavior
|
|
39
|
+
|
|
40
|
+
SIGINT and SIGTERM close FalkorDB with `SHUTDOWN NOSAVE`; shutdown does not force
|
|
41
|
+
an additional RDB by default. Opt in when the termination budget should be used
|
|
42
|
+
to save dirty data and upload it before exit:
|
|
43
|
+
|
|
44
|
+
```sh
|
|
45
|
+
dbx falkor-db \
|
|
46
|
+
--volume /Volumes/main/app_data/state/falkordb \
|
|
47
|
+
--profile WORKSPACE \
|
|
48
|
+
--force-backup-on-shutdown \
|
|
49
|
+
--shutdown-timeout-seconds 30
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
The CLI intentionally has no service command. Run it under the application or
|
|
53
|
+
container lifecycle that owns the graph.
|
|
54
|
+
|
|
55
|
+
<!-- cli-reference:start -->
|
|
56
|
+
|
|
57
|
+
## Command Reference
|
|
58
|
+
|
|
59
|
+
### `dbx falkor-db`
|
|
60
|
+
|
|
61
|
+
Run embedded FalkorDB with change-aware local and durable snapshots
|
|
62
|
+
|
|
63
|
+
```sh
|
|
64
|
+
dbx falkor-db [options]
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Options
|
|
68
|
+
|
|
69
|
+
| Option | Description |
|
|
70
|
+
| ---------------------------------------- | ----------------------------------------------------------------------------------------------------------- |
|
|
71
|
+
| `-v, --version` | output the version number |
|
|
72
|
+
| `--data-dir <value>` | Active local FalkorDB directory. (env: FALKORDB_DATA_DIR) |
|
|
73
|
+
| `--snapshot-seconds <value>` | Redis snapshot interval in seconds. (default: 300, env: FALKORDB_SNAPSHOT_SECONDS) |
|
|
74
|
+
| `--snapshot-min-changes <value>` | Writes required before an interval saves. (default: 1, env: FALKORDB_SNAPSHOT_MIN_CHANGES) |
|
|
75
|
+
| `--volume <value>` | Durable Unity Catalog Volume directory. (env: FALKORDB_VOLUME) |
|
|
76
|
+
| `--profile <value>` | Exact Databricks profile used for Volume access. (env: DATABRICKS_CONFIG_PROFILE) |
|
|
77
|
+
| `--retention <value>` | Durable snapshots retained. (default: 5, env: RETENTION) |
|
|
78
|
+
| `--backup-poll-seconds <value>` | Completed-RDB polling interval in seconds. (default: 10, env: BACKUP_POLL_SECONDS) |
|
|
79
|
+
| `--stale-backup-warning-seconds <value>` | Seconds before warning that changed data lacks a recent durable backup. (env: STALE_BACKUP_WARNING_SECONDS) |
|
|
80
|
+
| `--force-backup-on-shutdown` | Force a dirty RDB and durable upload before shutdown. (default: false, env: FORCE_BACKUP_ON_SHUTDOWN) |
|
|
81
|
+
| `--no-force-backup-on-shutdown` | Disable force a dirty rdb and durable upload before shutdown. |
|
|
82
|
+
| `--shutdown-timeout-seconds <value>` | Shutdown backup timeout in seconds. (default: 30, env: SHUTDOWN_TIMEOUT_SECONDS) |
|
|
83
|
+
| `--redis-server-path <value>` | Custom redis-server executable. (env: REDIS_SERVER_PATH) |
|
|
84
|
+
| `--module-path <value>` | Custom FalkorDB module. (env: MODULE_PATH) |
|
|
85
|
+
| `--max-memory <value>` | Redis memory limit such as 256mb. (env: MAX_MEMORY) |
|
|
86
|
+
| `--redis-log-level <value>` | Redis log level. (choices: "debug", "verbose", "notice", "warning", env: REDIS_LOG_LEVEL) |
|
|
87
|
+
| `--redis-log-file <value>` | Redis log file. (env: REDIS_LOG_FILE) |
|
|
88
|
+
| `--startup-timeout-seconds <value>` | Embedded server startup timeout in seconds. (default: 10, env: STARTUP_TIMEOUT_SECONDS) |
|
|
89
|
+
| `--inherit-stdio` | Inherit redis-server stdout and stderr. (default: false, env: INHERIT_STDIO) |
|
|
90
|
+
| `--no-inherit-stdio` | Disable inherit redis-server stdout and stderr. |
|
|
91
|
+
|
|
92
|
+
<!-- cli-reference:end -->
|
package/index.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// GENERATED by projen watch - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
|
|
5
|
+
export const PACKAGE_IDENTIFIER = "@dbx-tools/cli-falkor-db";
|
|
6
|
+
export const PACKAGE_VERSION = "0.9.43";
|
|
7
|
+
export * as cli from "./src/cli.ts";
|
|
8
|
+
export * as options from "./src/options.ts";
|
|
9
|
+
export * as runtime from "./src/runtime.ts";
|
|
10
|
+
export type { FalkorDBCliDependencies } from "./src/cli.ts";
|
|
11
|
+
export { FalkorDBOptionsSchema } from "./src/options.ts";
|
|
12
|
+
export type { FalkorDBOptions } from "./src/options.ts";
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
import { buildProgram } from "../src/cli.js";
|
|
3
|
+
await buildProgram("dbx-falkor-db").parseAsync(process.argv);
|
|
4
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGJ4LWZhbGtvci1kYi5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL2Jpbi9kYngtZmFsa29yLWRiLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7QUFFQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBRTdDLE1BQU0sWUFBWSxDQUFDLGVBQWUsQ0FBQyxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsSUFBSSxDQUFDLENBQUMiLCJzb3VyY2VzQ29udGVudCI6WyIjIS91c3IvYmluL2VudiBidW5cblxuaW1wb3J0IHsgYnVpbGRQcm9ncmFtIH0gZnJvbSBcIi4uL3NyYy9jbGkudHNcIjtcblxuYXdhaXQgYnVpbGRQcm9ncmFtKFwiZGJ4LWZhbGtvci1kYlwiKS5wYXJzZUFzeW5jKHByb2Nlc3MuYXJndik7XG4iXX0=
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const PACKAGE_IDENTIFIER = "@dbx-tools/cli-falkor-db";
|
|
2
|
+
export declare const PACKAGE_VERSION = "0.9.43";
|
|
3
|
+
export * as cli from "./src/cli.ts";
|
|
4
|
+
export * as options from "./src/options.ts";
|
|
5
|
+
export * as runtime from "./src/runtime.ts";
|
|
6
|
+
export type { FalkorDBCliDependencies } from "./src/cli.ts";
|
|
7
|
+
export { FalkorDBOptionsSchema } from "./src/options.ts";
|
|
8
|
+
export type { FalkorDBOptions } from "./src/options.ts";
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// GENERATED by projen watch - DO NOT EDIT.
|
|
2
|
+
// Regenerated from the exporting modules in ./src.
|
|
3
|
+
// Hand edits are overwritten on the next watch; this file is read-only.
|
|
4
|
+
export const PACKAGE_IDENTIFIER = "@dbx-tools/cli-falkor-db";
|
|
5
|
+
export const PACKAGE_VERSION = "0.9.43";
|
|
6
|
+
export * as cli from "./src/cli.js";
|
|
7
|
+
export * as options from "./src/options.js";
|
|
8
|
+
export * as runtime from "./src/runtime.js";
|
|
9
|
+
export { FalkorDBOptionsSchema } from "./src/options.js";
|
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSwyQ0FBMkM7QUFDM0MsbURBQW1EO0FBQ25ELHdFQUF3RTtBQUV4RSxNQUFNLENBQUMsTUFBTSxrQkFBa0IsR0FBRywwQkFBMEIsQ0FBQztBQUM3RCxNQUFNLENBQUMsTUFBTSxlQUFlLEdBQUcsUUFBUSxDQUFDO0FBQ3hDLE9BQU8sS0FBSyxHQUFHLE1BQU0sY0FBYyxDQUFDO0FBQ3BDLE9BQU8sS0FBSyxPQUFPLE1BQU0sa0JBQWtCLENBQUM7QUFDNUMsT0FBTyxLQUFLLE9BQU8sTUFBTSxrQkFBa0IsQ0FBQztBQUU1QyxPQUFPLEVBQUUscUJBQXFCLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbIi8vIEdFTkVSQVRFRCBieSBwcm9qZW4gd2F0Y2ggLSBETyBOT1QgRURJVC5cbi8vIFJlZ2VuZXJhdGVkIGZyb20gdGhlIGV4cG9ydGluZyBtb2R1bGVzIGluIC4vc3JjLlxuLy8gSGFuZCBlZGl0cyBhcmUgb3ZlcndyaXR0ZW4gb24gdGhlIG5leHQgd2F0Y2g7IHRoaXMgZmlsZSBpcyByZWFkLW9ubHkuXG5cbmV4cG9ydCBjb25zdCBQQUNLQUdFX0lERU5USUZJRVIgPSBcIkBkYngtdG9vbHMvY2xpLWZhbGtvci1kYlwiO1xuZXhwb3J0IGNvbnN0IFBBQ0tBR0VfVkVSU0lPTiA9IFwiMC45LjQzXCI7XG5leHBvcnQgKiBhcyBjbGkgZnJvbSBcIi4vc3JjL2NsaS50c1wiO1xuZXhwb3J0ICogYXMgb3B0aW9ucyBmcm9tIFwiLi9zcmMvb3B0aW9ucy50c1wiO1xuZXhwb3J0ICogYXMgcnVudGltZSBmcm9tIFwiLi9zcmMvcnVudGltZS50c1wiO1xuZXhwb3J0IHR5cGUgeyBGYWxrb3JEQkNsaURlcGVuZGVuY2llcyB9IGZyb20gXCIuL3NyYy9jbGkudHNcIjtcbmV4cG9ydCB7IEZhbGtvckRCT3B0aW9uc1NjaGVtYSB9IGZyb20gXCIuL3NyYy9vcHRpb25zLnRzXCI7XG5leHBvcnQgdHlwZSB7IEZhbGtvckRCT3B0aW9ucyB9IGZyb20gXCIuL3NyYy9vcHRpb25zLnRzXCI7XG4iXX0=
|
package/lib/src/cli.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commander parser for the foreground embedded FalkorDB CLI.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single owner for user-facing command names, defaults,
|
|
5
|
+
* environment variables, validation, and generated help. It intentionally has
|
|
6
|
+
* no service subcommand or dependency on `@dbx-tools/cli-service`.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { Command } from "commander";
|
|
11
|
+
import { type FalkorDBOptions } from "./options.ts";
|
|
12
|
+
/** Injectable foreground runtime boundary for CLI composition and tests. */
|
|
13
|
+
export interface FalkorDBCliDependencies {
|
|
14
|
+
run(options: FalkorDBOptions): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
/** Build the foreground-only FalkorDB command without starting the database. */
|
|
17
|
+
export declare function buildProgram(name?: string, dependencies?: FalkorDBCliDependencies): Command;
|
package/lib/src/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commander parser for the foreground embedded FalkorDB CLI.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single owner for user-facing command names, defaults,
|
|
5
|
+
* environment variables, validation, and generated help. It intentionally has
|
|
6
|
+
* no service subcommand or dependency on `@dbx-tools/cli-service`.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { addArgs, parseArgs } from "@dbx-tools/cli-args/args";
|
|
11
|
+
import { Command } from "commander";
|
|
12
|
+
import { PACKAGE_VERSION } from "../index.js";
|
|
13
|
+
import { FalkorDBOptionsSchema } from "./options.js";
|
|
14
|
+
import { runFalkorDB } from "./runtime.js";
|
|
15
|
+
const DEFAULT_DEPENDENCIES = { run: runFalkorDB };
|
|
16
|
+
/** Build the foreground-only FalkorDB command without starting the database. */
|
|
17
|
+
export function buildProgram(name = "dbx falkor-db", dependencies = DEFAULT_DEPENDENCIES) {
|
|
18
|
+
const program = addArgs(new Command()
|
|
19
|
+
.name(name)
|
|
20
|
+
.description("Run embedded FalkorDB with change-aware local and durable snapshots")
|
|
21
|
+
.showHelpAfterError()
|
|
22
|
+
.version(PACKAGE_VERSION, "-v, --version"), FalkorDBOptionsSchema, { scope: [] });
|
|
23
|
+
return program.action(async () => {
|
|
24
|
+
await dependencies.run(parseArgs(program, FalkorDBOptionsSchema));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xpLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vc3JjL2NsaS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7Ozs7R0FRRztBQUVILE9BQU8sRUFBRSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0sMEJBQTBCLENBQUM7QUFDOUQsT0FBTyxFQUFFLE9BQU8sRUFBRSxNQUFNLFdBQVcsQ0FBQztBQUVwQyxPQUFPLEVBQUUsZUFBZSxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBQzlDLE9BQU8sRUFBRSxxQkFBcUIsRUFBd0IsTUFBTSxjQUFjLENBQUM7QUFDM0UsT0F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RU5ERU5DSUVTLFxuKTogQ29tbWFuZCB7XG4gIGNvbnN0IHByb2dyYW0gPSBhZGRBcmdzKFxuICAgIG5ldyBDb21tYW5kKClcbiAgICAgIC5uYW1lKG5hbWUpXG4gICAgICAuZGVzY3JpcHRpb24oXCJSdW4gZW1iZWRkZWQgRmFsa29yREIgd2l0aCBjaGFuZ2UtYXdhcmUgbG9jYWwgYW5kIGR1cmFibGUgc25hcHNob3RzXCIpXG4gICAgICAuc2hvd0hlbHBBZnRlckVycm9yKClcbiAgICAgIC52ZXJzaW9uKFBBQ0tBR0VfVkVSU0lPTiwgXCItdiwgLS12ZXJzaW9uXCIpLFxuICAgIEZhbGtvckRCT3B0aW9uc1NjaGVtYSxcbiAgICB7IHNjb3BlOiBbXSB9LFxuICApO1xuICByZXR1cm4gcHJvZ3JhbS5hY3Rpb24oYXN5bmMgKCkgPT4ge1xuICAgIGF3YWl0IGRlcGVuZGVuY2llcy5ydW4ocGFyc2VBcmdzKHByb2dyYW0sIEZhbGtvckRCT3B0aW9uc1NjaGVtYSkpO1xuICB9KTtcbn1cbiJdfQ==
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground FalkorDB CLI configuration.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
export declare const FalkorDBOptionsSchema: z.ZodObject<{
|
|
8
|
+
dataDir: z.ZodOptional<z.ZodString>;
|
|
9
|
+
snapshotSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
10
|
+
snapshotMinChanges: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
11
|
+
volume: z.ZodOptional<z.ZodString>;
|
|
12
|
+
profile: z.ZodOptional<z.ZodString>;
|
|
13
|
+
retention: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
14
|
+
backupPollSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
15
|
+
staleBackupWarningSeconds: z.ZodOptional<z.ZodCoercedNumber<number>>;
|
|
16
|
+
forceBackupOnShutdown: z.ZodDefault<z.ZodBoolean>;
|
|
17
|
+
shutdownTimeoutSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
18
|
+
redisServerPath: z.ZodOptional<z.ZodString>;
|
|
19
|
+
modulePath: z.ZodOptional<z.ZodString>;
|
|
20
|
+
maxMemory: z.ZodOptional<z.ZodString>;
|
|
21
|
+
redisLogLevel: z.ZodOptional<z.ZodEnum<{
|
|
22
|
+
debug: "debug";
|
|
23
|
+
verbose: "verbose";
|
|
24
|
+
notice: "notice";
|
|
25
|
+
warning: "warning";
|
|
26
|
+
}>>;
|
|
27
|
+
redisLogFile: z.ZodOptional<z.ZodString>;
|
|
28
|
+
startupTimeoutSeconds: z.ZodDefault<z.ZodCoercedNumber<number>>;
|
|
29
|
+
inheritStdio: z.ZodDefault<z.ZodBoolean>;
|
|
30
|
+
}, z.core.$strict>;
|
|
31
|
+
export type FalkorDBOptions = z.output<typeof FalkorDBOptionsSchema>;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground FalkorDB CLI configuration.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
import { options } from "@dbx-tools/shared-core";
|
|
7
|
+
import { z } from "zod";
|
|
8
|
+
const text = (description) => z.string().trim().min(1).optional().describe(description);
|
|
9
|
+
const positiveInteger = (description) => z.coerce.number().int().positive().describe(description);
|
|
10
|
+
export const FalkorDBOptionsSchema = z
|
|
11
|
+
.object({
|
|
12
|
+
dataDir: text("Active local FalkorDB directory.").meta({ env: "FALKORDB_DATA_DIR" }),
|
|
13
|
+
snapshotSeconds: positiveInteger("Redis snapshot interval in seconds.")
|
|
14
|
+
.default(300)
|
|
15
|
+
.meta({ env: "FALKORDB_SNAPSHOT_SECONDS" }),
|
|
16
|
+
snapshotMinChanges: positiveInteger("Writes required before an interval saves.")
|
|
17
|
+
.default(1)
|
|
18
|
+
.meta({ env: "FALKORDB_SNAPSHOT_MIN_CHANGES" }),
|
|
19
|
+
volume: text("Durable Unity Catalog Volume directory.").meta({ env: "FALKORDB_VOLUME" }),
|
|
20
|
+
profile: options.DatabricksOptionsSchema.shape.profile.describe("Exact Databricks profile used for Volume access."),
|
|
21
|
+
retention: positiveInteger("Durable snapshots retained.").default(5),
|
|
22
|
+
backupPollSeconds: positiveInteger("Completed-RDB polling interval in seconds.").default(10),
|
|
23
|
+
staleBackupWarningSeconds: positiveInteger("Seconds before warning that changed data lacks a recent durable backup.").optional(),
|
|
24
|
+
forceBackupOnShutdown: z
|
|
25
|
+
.boolean()
|
|
26
|
+
.default(false)
|
|
27
|
+
.describe("Force a dirty RDB and durable upload before shutdown."),
|
|
28
|
+
shutdownTimeoutSeconds: positiveInteger("Shutdown backup timeout in seconds.").default(30),
|
|
29
|
+
redisServerPath: text("Custom redis-server executable."),
|
|
30
|
+
modulePath: text("Custom FalkorDB module."),
|
|
31
|
+
maxMemory: text("Redis memory limit such as 256mb."),
|
|
32
|
+
redisLogLevel: z
|
|
33
|
+
.enum(["debug", "verbose", "notice", "warning"])
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Redis log level."),
|
|
36
|
+
redisLogFile: text("Redis log file."),
|
|
37
|
+
startupTimeoutSeconds: positiveInteger("Embedded server startup timeout in seconds.").default(10),
|
|
38
|
+
inheritStdio: z.boolean().default(false).describe("Inherit redis-server stdout and stderr."),
|
|
39
|
+
})
|
|
40
|
+
.strict()
|
|
41
|
+
.describe("Foreground embedded FalkorDB command-line options.");
|
|
42
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoib3B0aW9ucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9vcHRpb25zLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7O0dBSUc7QUFFSCxPQUFPLEVBQUUsT0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xuICB9KVxuICAuc3RyaWN0KClcbiAgLmRlc2NyaWJlKFwiRm9yZWdyb3VuZCBlbWJlZGRlZCBGYWxrb3JEQiBjb21tYW5kLWxpbmUgb3B0aW9ucy5cIik7XG5cbmV4cG9ydCB0eXBlIEZhbGtvckRCT3B0aW9ucyA9IHoub3V0cHV0PHR5cGVvZiBGYWxrb3JEQk9wdGlvbnNTY2hlbWE+O1xuIl19
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground embedded FalkorDB process and optional Volume storage wiring.
|
|
3
|
+
*
|
|
4
|
+
* This module owns terminal signal handling and Databricks profile selection
|
|
5
|
+
* for the CLI. Reuse {@link runFalkorDB} from CLI entry points instead of
|
|
6
|
+
* duplicating process lifetime or Volume client construction.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import type { FalkorDBOptions } from "./options.ts";
|
|
11
|
+
/** Run FalkorDB until SIGINT or SIGTERM, then close it without an implicit save. */
|
|
12
|
+
export declare function runFalkorDB(options: FalkorDBOptions): Promise<void>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground embedded FalkorDB process and optional Volume storage wiring.
|
|
3
|
+
*
|
|
4
|
+
* This module owns terminal signal handling and Databricks profile selection
|
|
5
|
+
* for the CLI. Reuse {@link runFalkorDB} from CLI entry points instead of
|
|
6
|
+
* duplicating process lifetime or Volume client construction.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
import { workspaceClient } from "@dbx-tools/databricks";
|
|
11
|
+
import { DatabricksFileSystem } from "@dbx-tools/databricks/databricks-fs";
|
|
12
|
+
import { DatabricksVolumeStorage, DurableFalkorDB } from "@dbx-tools/falkor-db";
|
|
13
|
+
import { log } from "@dbx-tools/shared-core";
|
|
14
|
+
const logger = log.logger("cli:falkor-db");
|
|
15
|
+
/** Run FalkorDB until SIGINT or SIGTERM, then close it without an implicit save. */
|
|
16
|
+
export async function runFalkorDB(options) {
|
|
17
|
+
const storage = options.volume ? await volumeStorage(options.volume, options.profile) : undefined;
|
|
18
|
+
const database = await DurableFalkorDB.open({
|
|
19
|
+
...(options.dataDir ? { dataDir: options.dataDir } : {}),
|
|
20
|
+
snapshotSeconds: options.snapshotSeconds,
|
|
21
|
+
snapshotMinChanges: options.snapshotMinChanges,
|
|
22
|
+
...(storage ? { storage } : {}),
|
|
23
|
+
...(options.redisServerPath ? { redisServerPath: options.redisServerPath } : {}),
|
|
24
|
+
...(options.modulePath ? { modulePath: options.modulePath } : {}),
|
|
25
|
+
...(options.maxMemory ? { maxMemory: options.maxMemory } : {}),
|
|
26
|
+
...(options.redisLogLevel ? { logLevel: options.redisLogLevel } : {}),
|
|
27
|
+
...(options.redisLogFile ? { logFile: options.redisLogFile } : {}),
|
|
28
|
+
timeout: options.startupTimeoutSeconds * 1000,
|
|
29
|
+
inheritStdio: options.inheritStdio,
|
|
30
|
+
handleSignals: false,
|
|
31
|
+
persistence: {
|
|
32
|
+
pollIntervalMs: options.backupPollSeconds * 1000,
|
|
33
|
+
retention: options.retention,
|
|
34
|
+
forceBackupOnShutdown: options.forceBackupOnShutdown ?? false,
|
|
35
|
+
shutdownTimeoutMs: options.shutdownTimeoutSeconds * 1000,
|
|
36
|
+
...(options.staleBackupWarningSeconds === undefined
|
|
37
|
+
? {}
|
|
38
|
+
: { staleBackupWarningMs: options.staleBackupWarningSeconds * 1000 }),
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
logger.info("foreground FalkorDB started", {
|
|
42
|
+
pid: database.pid,
|
|
43
|
+
socketPath: database.socketPath,
|
|
44
|
+
durableStorage: Boolean(storage),
|
|
45
|
+
});
|
|
46
|
+
const shutdown = waitForShutdown();
|
|
47
|
+
try {
|
|
48
|
+
await shutdown.promise;
|
|
49
|
+
}
|
|
50
|
+
finally {
|
|
51
|
+
await database.close();
|
|
52
|
+
shutdown.dispose();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function volumeStorage(root, profile) {
|
|
56
|
+
const client = workspaceClient.toLegacyWorkspaceClient(await workspaceClient.createWorkspaceClient({ ...(profile ? { profile } : {}) }));
|
|
57
|
+
return new DatabricksVolumeStorage(new DatabricksFileSystem({ root, client, createRoot: true }));
|
|
58
|
+
}
|
|
59
|
+
function waitForShutdown() {
|
|
60
|
+
let resolve;
|
|
61
|
+
let requested = false;
|
|
62
|
+
const promise = new Promise((value) => {
|
|
63
|
+
resolve = value;
|
|
64
|
+
});
|
|
65
|
+
const handlers = new Map();
|
|
66
|
+
for (const signal of ["SIGINT", "SIGTERM"]) {
|
|
67
|
+
const handler = () => {
|
|
68
|
+
if (requested)
|
|
69
|
+
return;
|
|
70
|
+
requested = true;
|
|
71
|
+
resolve();
|
|
72
|
+
};
|
|
73
|
+
handlers.set(signal, handler);
|
|
74
|
+
process.on(signal, handler);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
promise,
|
|
78
|
+
dispose() {
|
|
79
|
+
for (const [signal, handler] of handlers)
|
|
80
|
+
process.off(signal, handler);
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicnVudGltZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9ydW50aW1lLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7OztHQVFHO0FBRUgsT0FBTyxFQUFFLGVBQWUsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3hELE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHFDQUFxQyxDQUFDO0FBQzNFLE9BQU8sRUFBRSx1QkFBdUIsRUFBRSxlQUFlLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUNoRixPQUFPLEVBQUUsR0FBRyxFQUFFLE1BQU0sd0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VyKTtcbiAgICB9LFxuICB9O1xufVxuIl19
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"root":["../src/cli.ts","../src/options.ts","../src/runtime.ts","../index.ts","../bin/dbx-falkor-db.ts"],"version":"5.9.3"}
|
package/package.json
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dbx-tools/cli-falkor-db",
|
|
3
|
+
"description": "Foreground embedded FalkorDB CLI with optional Databricks Volume backups",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "git+https://github.com/reggie-db/dbx-tools.git",
|
|
7
|
+
"directory": "packages/js/cli/falkor-db"
|
|
8
|
+
},
|
|
9
|
+
"bin": {
|
|
10
|
+
"dbx-falkor-db": "./lib/bin/dbx-falkor-db.js"
|
|
11
|
+
},
|
|
12
|
+
"scripts": {
|
|
13
|
+
"build": "projen build",
|
|
14
|
+
"compile": "projen compile",
|
|
15
|
+
"default": "projen default",
|
|
16
|
+
"package": "projen package",
|
|
17
|
+
"post-compile": "projen post-compile",
|
|
18
|
+
"pre-compile": "projen pre-compile",
|
|
19
|
+
"prepack": "projen prepack",
|
|
20
|
+
"test": "projen test",
|
|
21
|
+
"watch": "projen watch",
|
|
22
|
+
"projen": "projen"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/node": "^24.6.0",
|
|
26
|
+
"typescript": "^5.9.3"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"@dbx-tools/cli-args": "^0.9.43",
|
|
30
|
+
"@dbx-tools/databricks": "^0.9.43",
|
|
31
|
+
"@dbx-tools/falkor-db": "^0.9.43",
|
|
32
|
+
"@dbx-tools/shared-core": "^0.9.43",
|
|
33
|
+
"commander": "^15.0.0",
|
|
34
|
+
"zod": "4.3.6"
|
|
35
|
+
},
|
|
36
|
+
"main": "./lib/index.js",
|
|
37
|
+
"license": "Apache-2.0",
|
|
38
|
+
"publishConfig": {
|
|
39
|
+
"access": "public",
|
|
40
|
+
"main": "./lib/index.js",
|
|
41
|
+
"types": "./lib/index.d.ts",
|
|
42
|
+
"bin": {
|
|
43
|
+
"dbx-falkor-db": "./lib/bin/dbx-falkor-db.js"
|
|
44
|
+
},
|
|
45
|
+
"exports": {
|
|
46
|
+
".": {
|
|
47
|
+
"types": "./lib/index.d.ts",
|
|
48
|
+
"default": "./lib/index.js"
|
|
49
|
+
},
|
|
50
|
+
"./cli": {
|
|
51
|
+
"types": "./lib/src/cli.d.ts",
|
|
52
|
+
"default": "./lib/src/cli.js"
|
|
53
|
+
},
|
|
54
|
+
"./options": {
|
|
55
|
+
"types": "./lib/src/options.d.ts",
|
|
56
|
+
"default": "./lib/src/options.js"
|
|
57
|
+
},
|
|
58
|
+
"./runtime": {
|
|
59
|
+
"types": "./lib/src/runtime.d.ts",
|
|
60
|
+
"default": "./lib/src/runtime.js"
|
|
61
|
+
},
|
|
62
|
+
"./package.json": "./package.json"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
"version": "0.9.43",
|
|
66
|
+
"types": "./lib/index.d.ts",
|
|
67
|
+
"dbxToolsConfig": {
|
|
68
|
+
"tags": [
|
|
69
|
+
"cli"
|
|
70
|
+
]
|
|
71
|
+
},
|
|
72
|
+
"type": "module",
|
|
73
|
+
"exports": {
|
|
74
|
+
".": {
|
|
75
|
+
"types": "./lib/index.d.ts",
|
|
76
|
+
"default": "./lib/index.js"
|
|
77
|
+
},
|
|
78
|
+
"./cli": {
|
|
79
|
+
"types": "./lib/src/cli.d.ts",
|
|
80
|
+
"default": "./lib/src/cli.js"
|
|
81
|
+
},
|
|
82
|
+
"./options": {
|
|
83
|
+
"types": "./lib/src/options.d.ts",
|
|
84
|
+
"default": "./lib/src/options.js"
|
|
85
|
+
},
|
|
86
|
+
"./runtime": {
|
|
87
|
+
"types": "./lib/src/runtime.d.ts",
|
|
88
|
+
"default": "./lib/src/runtime.js"
|
|
89
|
+
},
|
|
90
|
+
"./package.json": "./package.json"
|
|
91
|
+
},
|
|
92
|
+
"files": [
|
|
93
|
+
"index.ts",
|
|
94
|
+
"src",
|
|
95
|
+
"bin",
|
|
96
|
+
"lib"
|
|
97
|
+
],
|
|
98
|
+
"//": "~~ Generated by projen. To modify, edit .projenrc.js and run \"bunx projen\"."
|
|
99
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commander parser for the foreground embedded FalkorDB CLI.
|
|
3
|
+
*
|
|
4
|
+
* This module is the single owner for user-facing command names, defaults,
|
|
5
|
+
* environment variables, validation, and generated help. It intentionally has
|
|
6
|
+
* no service subcommand or dependency on `@dbx-tools/cli-service`.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { addArgs, parseArgs } from "@dbx-tools/cli-args/args";
|
|
12
|
+
import { Command } from "commander";
|
|
13
|
+
|
|
14
|
+
import { PACKAGE_VERSION } from "../index.ts";
|
|
15
|
+
import { FalkorDBOptionsSchema, type FalkorDBOptions } from "./options.ts";
|
|
16
|
+
import { runFalkorDB } from "./runtime.ts";
|
|
17
|
+
|
|
18
|
+
/** Injectable foreground runtime boundary for CLI composition and tests. */
|
|
19
|
+
export interface FalkorDBCliDependencies {
|
|
20
|
+
run(options: FalkorDBOptions): Promise<void>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const DEFAULT_DEPENDENCIES: FalkorDBCliDependencies = { run: runFalkorDB };
|
|
24
|
+
|
|
25
|
+
/** Build the foreground-only FalkorDB command without starting the database. */
|
|
26
|
+
export function buildProgram(
|
|
27
|
+
name = "dbx falkor-db",
|
|
28
|
+
dependencies: FalkorDBCliDependencies = DEFAULT_DEPENDENCIES,
|
|
29
|
+
): Command {
|
|
30
|
+
const program = addArgs(
|
|
31
|
+
new Command()
|
|
32
|
+
.name(name)
|
|
33
|
+
.description("Run embedded FalkorDB with change-aware local and durable snapshots")
|
|
34
|
+
.showHelpAfterError()
|
|
35
|
+
.version(PACKAGE_VERSION, "-v, --version"),
|
|
36
|
+
FalkorDBOptionsSchema,
|
|
37
|
+
{ scope: [] },
|
|
38
|
+
);
|
|
39
|
+
return program.action(async () => {
|
|
40
|
+
await dependencies.run(parseArgs(program, FalkorDBOptionsSchema));
|
|
41
|
+
});
|
|
42
|
+
}
|
package/src/options.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground FalkorDB CLI configuration.
|
|
3
|
+
*
|
|
4
|
+
* @module
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { options } from "@dbx-tools/shared-core";
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
|
|
10
|
+
const text = (description: string) => z.string().trim().min(1).optional().describe(description);
|
|
11
|
+
const positiveInteger = (description: string) =>
|
|
12
|
+
z.coerce.number<number>().int().positive().describe(description);
|
|
13
|
+
|
|
14
|
+
export const FalkorDBOptionsSchema = z
|
|
15
|
+
.object({
|
|
16
|
+
dataDir: text("Active local FalkorDB directory.").meta({ env: "FALKORDB_DATA_DIR" }),
|
|
17
|
+
snapshotSeconds: positiveInteger("Redis snapshot interval in seconds.")
|
|
18
|
+
.default(300)
|
|
19
|
+
.meta({ env: "FALKORDB_SNAPSHOT_SECONDS" }),
|
|
20
|
+
snapshotMinChanges: positiveInteger("Writes required before an interval saves.")
|
|
21
|
+
.default(1)
|
|
22
|
+
.meta({ env: "FALKORDB_SNAPSHOT_MIN_CHANGES" }),
|
|
23
|
+
volume: text("Durable Unity Catalog Volume directory.").meta({ env: "FALKORDB_VOLUME" }),
|
|
24
|
+
profile: options.DatabricksOptionsSchema.shape.profile.describe(
|
|
25
|
+
"Exact Databricks profile used for Volume access.",
|
|
26
|
+
),
|
|
27
|
+
retention: positiveInteger("Durable snapshots retained.").default(5),
|
|
28
|
+
backupPollSeconds: positiveInteger("Completed-RDB polling interval in seconds.").default(10),
|
|
29
|
+
staleBackupWarningSeconds: positiveInteger(
|
|
30
|
+
"Seconds before warning that changed data lacks a recent durable backup.",
|
|
31
|
+
).optional(),
|
|
32
|
+
forceBackupOnShutdown: z
|
|
33
|
+
.boolean()
|
|
34
|
+
.default(false)
|
|
35
|
+
.describe("Force a dirty RDB and durable upload before shutdown."),
|
|
36
|
+
shutdownTimeoutSeconds: positiveInteger("Shutdown backup timeout in seconds.").default(30),
|
|
37
|
+
redisServerPath: text("Custom redis-server executable."),
|
|
38
|
+
modulePath: text("Custom FalkorDB module."),
|
|
39
|
+
maxMemory: text("Redis memory limit such as 256mb."),
|
|
40
|
+
redisLogLevel: z
|
|
41
|
+
.enum(["debug", "verbose", "notice", "warning"])
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Redis log level."),
|
|
44
|
+
redisLogFile: text("Redis log file."),
|
|
45
|
+
startupTimeoutSeconds: positiveInteger("Embedded server startup timeout in seconds.").default(
|
|
46
|
+
10,
|
|
47
|
+
),
|
|
48
|
+
inheritStdio: z.boolean().default(false).describe("Inherit redis-server stdout and stderr."),
|
|
49
|
+
})
|
|
50
|
+
.strict()
|
|
51
|
+
.describe("Foreground embedded FalkorDB command-line options.");
|
|
52
|
+
|
|
53
|
+
export type FalkorDBOptions = z.output<typeof FalkorDBOptionsSchema>;
|
package/src/runtime.ts
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Foreground embedded FalkorDB process and optional Volume storage wiring.
|
|
3
|
+
*
|
|
4
|
+
* This module owns terminal signal handling and Databricks profile selection
|
|
5
|
+
* for the CLI. Reuse {@link runFalkorDB} from CLI entry points instead of
|
|
6
|
+
* duplicating process lifetime or Volume client construction.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { workspaceClient } from "@dbx-tools/databricks";
|
|
12
|
+
import { DatabricksFileSystem } from "@dbx-tools/databricks/databricks-fs";
|
|
13
|
+
import { DatabricksVolumeStorage, DurableFalkorDB } from "@dbx-tools/falkor-db";
|
|
14
|
+
import { log } from "@dbx-tools/shared-core";
|
|
15
|
+
|
|
16
|
+
import type { FalkorDBOptions } from "./options.ts";
|
|
17
|
+
|
|
18
|
+
const logger = log.logger("cli:falkor-db");
|
|
19
|
+
|
|
20
|
+
/** Run FalkorDB until SIGINT or SIGTERM, then close it without an implicit save. */
|
|
21
|
+
export async function runFalkorDB(options: FalkorDBOptions): Promise<void> {
|
|
22
|
+
const storage = options.volume ? await volumeStorage(options.volume, options.profile) : undefined;
|
|
23
|
+
const database = await DurableFalkorDB.open({
|
|
24
|
+
...(options.dataDir ? { dataDir: options.dataDir } : {}),
|
|
25
|
+
snapshotSeconds: options.snapshotSeconds,
|
|
26
|
+
snapshotMinChanges: options.snapshotMinChanges,
|
|
27
|
+
...(storage ? { storage } : {}),
|
|
28
|
+
...(options.redisServerPath ? { redisServerPath: options.redisServerPath } : {}),
|
|
29
|
+
...(options.modulePath ? { modulePath: options.modulePath } : {}),
|
|
30
|
+
...(options.maxMemory ? { maxMemory: options.maxMemory } : {}),
|
|
31
|
+
...(options.redisLogLevel ? { logLevel: options.redisLogLevel } : {}),
|
|
32
|
+
...(options.redisLogFile ? { logFile: options.redisLogFile } : {}),
|
|
33
|
+
timeout: options.startupTimeoutSeconds * 1000,
|
|
34
|
+
inheritStdio: options.inheritStdio,
|
|
35
|
+
handleSignals: false,
|
|
36
|
+
persistence: {
|
|
37
|
+
pollIntervalMs: options.backupPollSeconds * 1000,
|
|
38
|
+
retention: options.retention,
|
|
39
|
+
forceBackupOnShutdown: options.forceBackupOnShutdown ?? false,
|
|
40
|
+
shutdownTimeoutMs: options.shutdownTimeoutSeconds * 1000,
|
|
41
|
+
...(options.staleBackupWarningSeconds === undefined
|
|
42
|
+
? {}
|
|
43
|
+
: { staleBackupWarningMs: options.staleBackupWarningSeconds * 1000 }),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
logger.info("foreground FalkorDB started", {
|
|
47
|
+
pid: database.pid,
|
|
48
|
+
socketPath: database.socketPath,
|
|
49
|
+
durableStorage: Boolean(storage),
|
|
50
|
+
});
|
|
51
|
+
const shutdown = waitForShutdown();
|
|
52
|
+
try {
|
|
53
|
+
await shutdown.promise;
|
|
54
|
+
} finally {
|
|
55
|
+
await database.close();
|
|
56
|
+
shutdown.dispose();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
async function volumeStorage(root: string, profile?: string): Promise<DatabricksVolumeStorage> {
|
|
61
|
+
const client = workspaceClient.toLegacyWorkspaceClient(
|
|
62
|
+
await workspaceClient.createWorkspaceClient({ ...(profile ? { profile } : {}) }),
|
|
63
|
+
);
|
|
64
|
+
return new DatabricksVolumeStorage(new DatabricksFileSystem({ root, client, createRoot: true }));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface ShutdownWaiter {
|
|
68
|
+
readonly promise: Promise<void>;
|
|
69
|
+
dispose(): void;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function waitForShutdown(): ShutdownWaiter {
|
|
73
|
+
let resolve!: () => void;
|
|
74
|
+
let requested = false;
|
|
75
|
+
const promise = new Promise<void>((value) => {
|
|
76
|
+
resolve = value;
|
|
77
|
+
});
|
|
78
|
+
const handlers = new Map<NodeJS.Signals, () => void>();
|
|
79
|
+
for (const signal of ["SIGINT", "SIGTERM"] as const) {
|
|
80
|
+
const handler = () => {
|
|
81
|
+
if (requested) return;
|
|
82
|
+
requested = true;
|
|
83
|
+
resolve();
|
|
84
|
+
};
|
|
85
|
+
handlers.set(signal, handler);
|
|
86
|
+
process.on(signal, handler);
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
promise,
|
|
90
|
+
dispose() {
|
|
91
|
+
for (const [signal, handler] of handlers) process.off(signal, handler);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|