Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Criando um endpoint de streaming
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Felipe Mamud
October 19, 2017
Programming
84
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Criando um endpoint de streaming
Como criar um endpoint stream utilizando Spring Boot.
Felipe Mamud
October 19, 2017
More Decks by Felipe Mamud
See All by Felipe Mamud
Criando sua DSL com jparsec
ftmamud
0
120
Groovy como você nunca viu
ftmamud
0
2.3k
Erlang sem enrolação!
ftmamud
0
150
Gradle: o melhor amigo no build do seu software
ftmamud
0
150
Desenvolvendo software no mundo atual
ftmamud
0
120
Reactive Programming no mundo Java
ftmamud
0
230
Reactive Programming - Brincando com eficiência, composição e assíncronia
ftmamud
1
650
Concorrência em Java: do velho oeste a atualidade
ftmamud
0
140
Java Threads: O que há de errado com elas e como resolver?
ftmamud
0
140
Other Decks in Programming
See All in Programming
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
270
AI時代のコードレビューは人に向けるな、仕組みに向けろ
texmeijin
5
3.7k
R8 の設定見直しでアプリサイズ削減
andpad
0
220
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
220
dotNET_vulnclicker_intro.pdf
deka_morita
0
140
コードレビューのボトルネックを"する側"と"される側"の両面から解消する
yub0n
2
1.6k
Railsバージョンを4倍にした話
optim
0
350
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
5
5.1k
Simple Storage Service(S3) is not simple
iwatsukayura
0
290
残高管理から台帳サービスへの進化
artoy
1
200
phperだってパンチカードでコーディングしたい
o0h
PRO
0
330
RAG の “R” を Swift で覗いてみる 〜「意味から探す」検索の仕組み〜
nao_randd
0
160
Featured
See All Featured
Designing Powerful Visuals for Engaging Learning
tmiket
1
610
コードの90%をAIが書く世界で何が待っているのか / What awaits us in a world where 90% of the code is written by AI
rkaga
63
46k
Color Theory Basics | Prateek | Gurzu
gurzu
1
490
Thoughts on Productivity
jonyablonski
76
5.4k
The Art of Programming - Codeland 2020
erikaheidi
57
14k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
450
Being A Developer After 40
akosma
92
590k
AI: The stuff that nobody shows you
jnunemaker
PRO
10
1.2k
Become a Pro
speakerdeck
PRO
31
6.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
10k
WENDY [Excerpt]
tessaabrams
14
40k
Docker and Python
trallard
47
4.2k
Transcript
Criando um endpoint de streaming DANIEL MEZZATTO @mezzatto FELIPE MAMUD
@mamud
Então vc quer criar um endpoint stream?
AGENDA Stream.of("Motivação", "Desafios", "Endpoint") .map(VivaReal::techTalk) .collect(Collectors.knowledge());
MOTIVAÇÃO • Time to first byte (TTFB) • Deep paging
DESAFIOS • Qual implementação utilizar? ◦ Java? outra linguagem? ◦
Server-Sent Events ◦ StreamingResponseBody* ◦ Custom • ES SearchScroll (com shards) • Sized stream
CONTROLLER @RequestMapping(value = "/{index}/stream", method = GET) public StreamingResponseBody stream(
FilterableApiRequest request, HttpServletResponse httpServletResponse) { httpServletResponse .setContentType("application/x-ndjson;charset=UTF-8"); return out -> searchService.stream(request, out); }
@Component public class ElasticSearchStream { public void stream(OutputStream stream) {
ResponseStream.iterate(stream, new SearchApiIterator<>(esClient, requestBuilder(), scroll -> scroll.setScroll(keepAlive) .actionGet(streamTimeout), count), searchHit -> toBytes(searchHit.getSourceRef())); } } ELASTICSEARCH STREAM
RESPONSE STREAM public static <T> void iterate(OutputStream stream, Iterator<T[]> iterator,
Function<T, byte[]> byteFn) { while (iterator.hasNext()) { for (T hit: iterator.next()) { stream.write(byteFn.apply(hit)); stream.write('\n'); } stream.flush(); } }
SEARCH ITERATOR public class SearchApiIterator<T> implements Iterator<T[]> { @Override public
boolean hasNext() { return hits() > 0 && count <= size; } @Override public T[] next() { T[] result = (T[]) response.getHits().getHits(); response = loop.apply(client.prepareSearchScroll(response.getScrollId())); this.count += hits(); return result; } }|
None