-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SPT-1998 fix pr and some improvements
- Loading branch information
1 parent
c3e306d
commit 2e154a5
Showing
80 changed files
with
1,684 additions
and
1,206 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// AsyncCombineNode.swift | ||
// NodeKit | ||
// | ||
// Created by Andrei Frolov on 03.04.24. | ||
// Copyright © 2024 Surf. All rights reserved. | ||
// | ||
|
||
import Combine | ||
|
||
/// Реализация ``CombineNode`` для ``AsyncNode``. | ||
public struct AsyncCombineNode<Input, Output>: CombineNode { | ||
|
||
// MARK: - Private Properties | ||
|
||
private let node: any AsyncNode<Input, Output> | ||
|
||
// MARK: - Initialization | ||
|
||
init(node: some AsyncNode<Input, Output>) { | ||
self.node = node | ||
} | ||
|
||
// MARK: - CombineNode | ||
|
||
/// Метод запускающий процесс обработки данных | ||
/// и возвращающий publisher для подписки на результат. | ||
/// | ||
/// - Parameters: | ||
/// - data: Входные данные ноды. | ||
/// - queue: Очередь на которой будут выдаваться результаты. | ||
/// - logContext: Контекст логов. | ||
/// - Returns: Publisher для подписки на результат. | ||
public func nodeResultPublisher(for data: Input, on scheduler: some Scheduler, logContext: LoggingContextProtocol) -> AnyPublisher<NodeResult<Output>, Never> { | ||
return Future<NodeResult<Output>, Never> { promise in | ||
Task { | ||
let result = await node.process(data, logContext: logContext) | ||
promise(.success(result)) | ||
} | ||
} | ||
.receive(on: scheduler) | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
public func processLegacy(_ data: Input) -> Observer<Output> { | ||
return node.processLegacy(data) | ||
} | ||
} |
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,53 @@ | ||
// | ||
// AsyncStreamCombineNode.swift | ||
// NodeKit | ||
// | ||
// Created by Andrei Frolov on 03.04.24. | ||
// Copyright © 2024 Surf. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
import Combine | ||
|
||
/// Реализация ``CombineStreamNode`` для ``AsyncStreamNode``. | ||
public struct AsyncStreamCombineNode<Input, Output>: CombineStreamNode { | ||
|
||
// MARK: - Private Properties | ||
|
||
private let subject = PassthroughSubject<NodeResult<Output>, Never>() | ||
private let node: any AsyncStreamNode<Input, Output> | ||
|
||
// MARK: - Initialization | ||
|
||
init(node: some AsyncStreamNode<Input, Output>) { | ||
self.node = node | ||
} | ||
|
||
// MARK: - CombineNode | ||
|
||
/// Publisher результата обработки данных. | ||
/// - Parameter scheduler: Scheduler для выдачи результов. | ||
public func nodeResultPublisher(on scheduler: some Scheduler) -> AnyPublisher<NodeResult<Output>, Never> { | ||
return subject | ||
.receive(on: scheduler) | ||
.eraseToAnyPublisher() | ||
} | ||
|
||
/// Метод обработки данных протокола ``Node``. Будет удален в ближайшее время. | ||
public func processLegacy(_ data: Input) -> Observer<Output> { | ||
return node.processLegacy(data) | ||
} | ||
|
||
/// Метод запускающий процесс обработки данных. | ||
/// | ||
/// - Parameters: | ||
/// - data: Входные данные ноды. | ||
/// - logContext: Контекст логов. | ||
public func process(_ data: Input, logContext: LoggingContextProtocol) { | ||
Task { | ||
for await result in node.process(data, logContext: logContext) { | ||
subject.send(result) | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.