Skip to content
This repository was archived by the owner on Jan 27, 2023. It is now read-only.

Commit ba024ee

Browse files
committed
update rpc to send unique field and handle invalid arg error on put and put stream requests
1 parent c4e8248 commit ba024ee

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/cipherstash/client/rpc.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def create_collection(name, metadata, indexes)
7979
id: blob_from_uuid(idx[:meta]["$indexId"]),
8080
settings: encrypt_blob(idx.to_cbor, "createCollection"),
8181
type: index_type(idx[:mapping]["kind"]),
82+
unique: idx[:mapping]["unique"]
8283
}
8384
end
8485
)
@@ -103,6 +104,7 @@ def migrate_collection(name, metadata, indexes, from_schema_version)
103104
id: blob_from_uuid(idx[:meta]["$indexId"]),
104105
settings: encrypt_blob(idx.to_cbor, "migrateCollection"),
105106
type: index_type(idx[:mapping]["kind"]),
107+
unique: idx[:mapping]["unique"]
106108
}
107109
end,
108110
fromSchemaVersion: from_schema_version
@@ -158,6 +160,8 @@ def put(collection, id, record, vectors)
158160
uuid_from_blob(id)
159161
rescue ::GRPC::NotFound
160162
raise Error::RecordPutFailure, "Collection '#{collection.name}' not found"
163+
rescue ::GRPC::InvalidArgument => ex
164+
raise Error::RecordPutFailure, "Error while putting record into collection '#{collection.name}': #{ex.message} (#{ex.class})"
161165
rescue ::GRPC::BadStatus => ex
162166
raise Error::RecordPutFailure, "Error while putting records into collection '#{collection.name}': #{ex.message} (#{ex.class})"
163167
end
@@ -279,6 +283,10 @@ def put_stream(collection, records)
279283
res.numInserted
280284
rescue ::GRPC::NotFound
281285
raise Error::RecordDeleteFailure, "Collection '#{collection.name}' not found"
286+
rescue ::GRPC::InvalidArgument => ex
287+
raise Error::RecordPutFailure, "Error while putting records into collection '#{collection.name}': #{ex.message} (#{ex.class})"
288+
rescue ::GRPC::BadStatus => ex
289+
raise Error::RecordGetFailure, "Error while putting records into collection '#{collection.name}': #{ex.message} (#{ex.class})"
282290
end
283291

284292
def delete(collection, id)

0 commit comments

Comments
 (0)