-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SCRUM-51] StreamListener 개선 #66
Merged
Merged
Conversation
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
Jihyun247
force-pushed
the
feature/SCRUM-51
branch
from
December 27, 2024 14:09
daafdc9
to
c6e9fde
Compare
devMinseok
previously approved these changes
Dec 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
고생했어! 다 깔끔하게 잘 만들었고만 👍👍
이건 추가적인거긴 한데.. 단일 stream을 여러곳에서 receive하고자 할때는 문제가 있을거 같아서 배열로 관리를 해야할거 같넴
private actor StreamActor {
private var streams: [StreamKey: [StreamContinuation]] = [:]
func register<T: StreamType>(key: StreamKey, continuation: AsyncStream<T>.Continuation) {
let newContinuation = StreamContinuation(continuation)
if streams[key] == nil {
streams[key] = [newContinuation]
} else {
streams[key]?.append(newContinuation)
}
}
func yield<T: StreamType>(type: StreamKey, value: T) {
guard let continuations = streams[type] else { return }
continuations.forEach { $0.yield(value) }
}
func removeContinuation(key: StreamKey, continuation: StreamContinuation) {
streams[key]?.removeAll { $0 === continuation }
if streams[key]?.isEmpty == true {
streams[key] = nil
}
}
}
Projects/Core/StreamListener/Interface/StreamContinuation.swift
Outdated
Show resolved
Hide resolved
Projects/Core/StreamListener/Interface/StreamContinuation.swift
Outdated
Show resolved
Hide resolved
devMinseok
previously approved these changes
Dec 27, 2024
func removeContinuation(key: StreamKey, continuation: StreamContinuation) {
streams[key]?.removeAll { $0 === continuation }
if streams[key]?.isEmpty == true {
streams[key] = nil
}
} 여기에서 매개변수로 있는 continuation은 , 특정해서 하나의 continuation을 삭제할 일은 없을 것 같아서 func remove(key: StreamKey) {
streams[key]?.forEach { $0.finish() }
streams[key] = nil
} 이렇게 수정했는데 의견 있으면 알려죠 |
devMinseok
approved these changes
Dec 27, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[SCRUM-51] StreamListener 개선
무엇에 관한 PR 인가요? 🙋
남은 작업
재시도 스트림 객체 생성 및 로직 연결 (어려우ㅜ ㅓ ..)