Skip to content

Commit cc89dba

Browse files
committed
Rename ObjectStore -> KVStore
1 parent 0ebce7a commit cc89dba

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

Sources/Compute/Fastly/FastlyObjectStore.swift renamed to Sources/Compute/Fastly/FastlyKVStore.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import ComputeRuntime
99

1010
extension Fastly {
11-
public struct ObjectStore: Sendable {
11+
public struct KVStore: Sendable {
1212

1313
internal let handle: WasiHandle
1414

@@ -21,7 +21,7 @@ extension Fastly {
2121
self.name = name
2222
}
2323

24-
public func lookup(_ key: String) throws -> Body? {
24+
public func lookup(_ key: String) async throws -> Body? {
2525
do {
2626
var bodyHandle: WasiHandle = InvalidWasiHandle
2727
try wasi(fastly_object_store__lookup(handle, key, key.utf8.count, &bodyHandle))
@@ -31,14 +31,14 @@ extension Fastly {
3131
}
3232
}
3333

34-
public func insert(_ key: String, body: Body) throws {
34+
public func insert(_ key: String, body: Body) async throws {
3535
try wasi(fastly_object_store__insert(handle, key, key.utf8.count, body.handle))
3636
}
3737

38-
public func insert(_ key: String, bytes: [UInt8]) throws {
38+
public func insert(_ key: String, bytes: [UInt8]) async throws {
3939
var body = try Body()
4040
try body.write(bytes)
41-
try insert(key, body: body)
41+
try await insert(key, body: body)
4242
}
4343
}
4444
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
//
2-
// ObjectStore.swift
2+
// KVStore.swift
33
//
44
//
55
// Created by Andrew Barba on 3/31/22.
66
//
77

8-
public struct ObjectStore: Sendable {
8+
public struct KVStore: Sendable {
99

10-
internal let store: Fastly.ObjectStore
10+
internal let store: Fastly.KVStore
1111

1212
public init(name: String) throws {
1313
store = try .init(name: name)
@@ -20,7 +20,7 @@ public struct ObjectStore: Sendable {
2020

2121
// MARK: - Entry
2222

23-
extension ObjectStore {
23+
extension KVStore {
2424

2525
public struct Entry: Sendable {
2626

@@ -30,17 +30,17 @@ extension ObjectStore {
3030

3131
// MARK: - Read
3232

33-
extension ObjectStore {
33+
extension KVStore {
3434

3535
public func get(_ key: String) async throws -> Entry? {
36-
guard let body = try store.lookup(key) else {
36+
guard let body = try await store.lookup(key) else {
3737
return nil
3838
}
3939
return .init(body: ReadableWasiBody(body))
4040
}
4141

4242
public func has(_ key: String) async throws -> Bool {
43-
switch try store.lookup(key) {
43+
switch try await store.lookup(key) {
4444
case .some:
4545
return true
4646
case .none:
@@ -51,14 +51,14 @@ extension ObjectStore {
5151

5252
// MARK: - Update
5353

54-
extension ObjectStore {
54+
extension KVStore {
5555

5656
public func put(_ key: String, body: ReadableBody) async throws {
5757
try await store.insert(key, body: body.body)
5858
}
5959

6060
public func put(_ key: String, bytes: [UInt8]) async throws {
61-
try store.insert(key, bytes: bytes)
61+
try await store.insert(key, bytes: bytes)
6262
}
6363

6464
public func put(_ key: String, data: Data) async throws {

0 commit comments

Comments
 (0)