Skip to content

How can I get stream as flow with coroutine? #2116

Answered by wangmir
wangmir asked this question in Q&A
Discussion options

You must be logged in to vote

Oh, I realized that,

XReadArgs.StreamOffset.from("key", ">")

is working.

    @OptIn(ExperimentalLettuceCoroutinesApi::class)
    fun getStream(groupName: String): Flow<StreamMessage<String, String>> {
        return coroutine.xreadgroup(Consumer.from(groupName, "test-stream"), XReadArgs.StreamOffset.from("test-stream", ">"))
    }

This function properly provides flow for stream message.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by wangmir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant