loams 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +80 -2
- data/gen/loams-descriptor.binpb +0 -0
- data/lib/loams/app.rb +726 -0
- data/lib/loams/batch.rb +93 -0
- data/lib/loams/builders.rb +622 -0
- data/lib/loams/client.rb +76 -2
- data/lib/loams/consistency.rb +201 -0
- data/lib/loams/descriptors.rb +6 -0
- data/lib/loams/errors.rb +60 -0
- data/lib/loams/invoker.rb +41 -2
- data/lib/loams/subscribe.rb +75 -0
- data/lib/loams/transport.rb +5 -3
- data/lib/loams/values.rb +87 -0
- data/lib/loams/version.rb +1 -1
- data/lib/loams.rb +11 -0
- metadata +7 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: db184504f7f63fdf5e2ab833a12280e85b86829f46f05795c105e7f65e6ccc3d
|
|
4
|
+
data.tar.gz: 79eb774e3e96924074dcc6fd1d410cd38bd7cac598b746186fd25083eea1b9b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b7bc2ecdd06cd9091f1af5b14660a64bd1ece91db2cad5b7759c815bc738e3df076845afcca0893da5dde58f99ab64acbac2b5c7399e24834fa2949a6783a5ea
|
|
7
|
+
data.tar.gz: 80772148e8eab5750abeff443d49ca102507120a95ca5b09fcfa0878344de0e0ecc37dd68a2ccaf05e57954fc786d8f3eff3cdf5669f7125129c3e35805e0f01
|
data/README.md
CHANGED
|
@@ -14,7 +14,7 @@ gem install loams
|
|
|
14
14
|
or, in a `Gemfile`, pin the version exactly:
|
|
15
15
|
|
|
16
16
|
```ruby
|
|
17
|
-
gem "loams", "0.1.
|
|
17
|
+
gem "loams", "0.1.1"
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
A prerelease tag such as `v0.1.0-preview.2` is spelled `0.1.0.pre.2` on RubyGems and needs `--pre`. The gem needs
|
|
@@ -28,11 +28,89 @@ require "loams"
|
|
|
28
28
|
client = Loams.client("https://acme.loams.dev")
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
+
## Build an app
|
|
32
|
+
|
|
33
|
+
The app-building modules are `namespaces`, `collections`, `documents`,
|
|
34
|
+
`search`, `vector` and `graph` (experimental), with the `Schema`, `Filter` and
|
|
35
|
+
`Search` builders. [`examples/notes/notes.rb`](examples/notes/notes.rb) is the
|
|
36
|
+
whole flow:
|
|
37
|
+
|
|
38
|
+
```ruby
|
|
39
|
+
require "loams"
|
|
40
|
+
|
|
41
|
+
# LOAMS_ENDPOINT, LOAMS_API_KEY (or LOAMS_TOKEN) and LOAMS_NAMESPACE.
|
|
42
|
+
client = Loams.from_env(session_consistency: true)
|
|
43
|
+
# or: Loams::Client.new("http://127.0.0.1:8080", api_key: "…", namespace: "app", timeout: 30)
|
|
44
|
+
|
|
45
|
+
client.namespaces.create("app")
|
|
46
|
+
client.collections.create("notes", schema: Loams::Schema.new
|
|
47
|
+
.keyword("title").text("body").keyword("tags").i64("n").vector("embedding", 4))
|
|
48
|
+
|
|
49
|
+
notes = client.collection("notes")
|
|
50
|
+
notes.upsert([{ id: 1, source: { title: "Refunds", body: "refund policy", tags: ["policy"], n: 1 },
|
|
51
|
+
vectors: { embedding: [1, 0, 0, 0] } }])
|
|
52
|
+
|
|
53
|
+
hits = notes.search(
|
|
54
|
+
Loams::Search.on("notes")
|
|
55
|
+
.text("refund", fields: ["body"])
|
|
56
|
+
.vector("embedding", [1, 0, 0, 0])
|
|
57
|
+
.fuse(Loams::Fusion.rrf(60)) # or .dbsf, .weighted(0.7, 0.3)
|
|
58
|
+
.filter(Loams::Filter.eq("tags", "policy") & Loams::Filter.range("n", gte: 1))
|
|
59
|
+
.highlight("body")
|
|
60
|
+
.select(include: ["title"])
|
|
61
|
+
.limit(10),
|
|
62
|
+
).hits
|
|
63
|
+
hits.each { |h| puts Loams.to_h(h.source)["title"] }
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
- **Answers are messages.** `Loams.to_h(message)` turns one (or a `Struct`
|
|
67
|
+
such as `hit.source`) into plain Ruby; `Loams::Values.from_document_id(hit.pk)`
|
|
68
|
+
gives a key back as an Integer or a String.
|
|
69
|
+
- **Writes.** `documents.upsert`, `delete`, `patch` and `write` (raw ops) answer a
|
|
70
|
+
consistency `token`. `documents.write_batch(collection, enumerable, chunk_rows:,
|
|
71
|
+
chunk_bytes:)` sends chunks one at a time, each with its own idempotency key,
|
|
72
|
+
and answers a `Loams::BatchResult` (the merged `token`, `chunks`, `rows`); a
|
|
73
|
+
failed chunk raises `Loams::BatchError` with `chunks_applied` and the `token`
|
|
74
|
+
of the chunks before it.
|
|
75
|
+
- **Reads.** `documents.get`, `count`, `scroll` / `scroll_all`, `search.query`,
|
|
76
|
+
`search.query_all` (follows `search_after`; the sort must end with `Sort.pk`),
|
|
77
|
+
`search.text(collection, text, fields:)`,
|
|
78
|
+
`search.hybrid(collection, text, vector, field:, fields:, fusion:)` and
|
|
79
|
+
`vector.search(collection, vector, field:)`. Each takes `consistency:`
|
|
80
|
+
(`:strong`, `:eventual` or a token). With `session_consistency: true` every
|
|
81
|
+
token an answer carries is merged into the session and attached to later reads.
|
|
82
|
+
- **Graph** (experimental): `graph.create`, `query` (GQL, with Ruby `parameters:`),
|
|
83
|
+
`query_batch`, `explain`, `list_all`, `delete`; `Loams::App::Graph.records(res)`
|
|
84
|
+
gives rows as Hashes.
|
|
85
|
+
- **The default namespace** fills every request that names none; with neither,
|
|
86
|
+
the call raises `Loams::InvalidArgumentError` before any network call.
|
|
87
|
+
**Timeouts** default to 30 s per unary call (`timeout:` on the client or the call,
|
|
88
|
+
`nil` for none); a spent budget raises `Loams::DeadlineExceededError` with reason
|
|
89
|
+
`client_deadline_exceeded` and is never retried.
|
|
90
|
+
- **SQL.** `sql.query(sql, params: [...], max_rows:, consistency:)` answers
|
|
91
|
+
`columns` and `rows`; `Loams::App::Sql.records(res)` gives rows as Hashes.
|
|
92
|
+
`query_arrow` answers the Arrow IPC bytes. SQL reads see the session's
|
|
93
|
+
collection writes.
|
|
94
|
+
- **Streams.** `streams.create`, `get`, `list` / `list_all`, `produce(stream,
|
|
95
|
+
records, partition:, producer_id:, producer_seq:)` (a record is a String, a
|
|
96
|
+
JSON value, or `{key:, value:, headers:}` with an optional key; a repeated
|
|
97
|
+
producer sequence is deduplicated), `fetch` (`Loams::App::Streams.records(res)`
|
|
98
|
+
decodes it), `produce_events` / `fetch_events` (CloudEvents as Hashes), and
|
|
99
|
+
`subscribe(stream, partition:, from_offset:)`, a `Loams::Subscription` to
|
|
100
|
+
enumerate, `cancel` and resume from `offset`.
|
|
101
|
+
- Durable execution has no module: use the Resonate SDK with
|
|
102
|
+
`LOAMS_ENDPOINT/durable/` as its URL.
|
|
103
|
+
|
|
104
|
+
Every module's raw descriptor-derived calls stay reachable as
|
|
105
|
+
`client.module("collections")` and friends.
|
|
106
|
+
|
|
31
107
|
## Develop
|
|
32
108
|
|
|
33
109
|
```sh
|
|
34
110
|
bundle install
|
|
35
|
-
bundle exec rake test # the conformance suite
|
|
111
|
+
bundle exec rake test # the conformance suite and the app tests
|
|
112
|
+
LOAMS_TEST_ENDPOINT=http://127.0.0.1:8080 bundle exec rake test # plus the app scenario against `loams dev`
|
|
113
|
+
bundle exec rake descriptors # regenerate gen/loams-descriptor.binpb (needs buf)
|
|
36
114
|
gem build loams.gemspec # what sdk-release.yml publishes
|
|
37
115
|
```
|
|
38
116
|
|
data/gen/loams-descriptor.binpb
CHANGED
|
Binary file
|