-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Implementation] StreamClient.Subscribe.
[Refactor] some data structure form StreamClient.Read to Stream
- Loading branch information
Grady Zhuo
committed
Jun 23, 2024
1 parent
31c7187
commit 2f133a7
Showing
26 changed files
with
600 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
Sources/EventStoreDB/StreamClient/Stream/Stream.ControlOption.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// | ||
// Stream.ControlOption.swift | ||
// | ||
// | ||
// Created by Grady Zhuo on 2024/6/23. | ||
// | ||
|
||
extension Stream { | ||
public enum ControlOption: Sendable { | ||
case compatibility(UInt32) | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
Sources/EventStoreDB/StreamClient/Stream/Stream.Direction.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// Stream.Direction.swift | ||
// | ||
// | ||
// Created by Grady Zhuo on 2024/6/23. | ||
// | ||
|
||
extension Stream { | ||
public enum Direction: Sendable { | ||
case forward | ||
case backward | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
Sources/EventStoreDB/StreamClient/Stream/Stream.FilterOption.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
// | ||
// Stream.FilterOption.swift | ||
// | ||
// | ||
// Created by Grady Zhuo on 2024/6/23. | ||
// | ||
|
||
import GRPCEncapsulates | ||
|
||
extension Stream { | ||
public struct SubscriptionFilter: FluentInterfaceOptions { | ||
public enum Window: Sendable { | ||
case count | ||
case max(UInt32) | ||
} | ||
|
||
public enum FilterType: Sendable { | ||
case streamName(regex: String) | ||
case eventType(regex: String) | ||
} | ||
|
||
public internal(set) var type: FilterType | ||
public internal(set) var window: Window | ||
public internal(set) var prefixes: [String] | ||
public internal(set) var checkpointIntervalMultiplier: UInt32 | ||
|
||
init(type: FilterType, window: Window = .count, prefixes: [String] = []) { | ||
self.type = type | ||
self.window = window | ||
self.prefixes = prefixes | ||
checkpointIntervalMultiplier = .max | ||
} | ||
|
||
@discardableResult | ||
public static func onStreamName(regex: String) -> Self { | ||
.init(type: .streamName(regex: regex)) | ||
} | ||
|
||
@discardableResult | ||
public static func onEventType(regex: String) -> Self { | ||
.init(type: .eventType(regex: regex)) | ||
} | ||
|
||
@discardableResult | ||
public func set(max maxCount: UInt32) -> Self { | ||
withCopy { options in | ||
options.window = .max(maxCount) | ||
} | ||
} | ||
|
||
@discardableResult | ||
public func set(checkpointIntervalMultiplier multiplier: UInt32) -> Self { | ||
withCopy { options in | ||
options.checkpointIntervalMultiplier = multiplier | ||
} | ||
} | ||
|
||
@discardableResult | ||
public func add(prefix: String) -> Self { | ||
withCopy { options in | ||
options.prefixes.append(prefix) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
Sources/EventStoreDB/StreamClient/Stream/Stream.UUIDOption.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// | ||
// Stream.UUIDOption.swift | ||
// | ||
// | ||
// Created by Grady Zhuo on 2024/6/23. | ||
// | ||
import Foundation | ||
|
||
extension Stream{ | ||
public enum UUIDOption: Sendable { | ||
case structured | ||
case string | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.