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
Felipe Mamud
October 19, 2017
Programming
91
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
Transcript
10 slides
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
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
160
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
240
Reactive Programming - Brincando com eficiência, composição e assíncronia
ftmamud
1
660
Concorrência em Java: do velho oeste a atualidade
ftmamud
0
150
Java Threads: O que há de errado com elas e como resolver?
ftmamud
0
140
Other Decks in Programming
See All in Programming
Engineering Biometric UX Across Android Versions | DroidKnights 2026
ryunen344
1
220
ローカルLLMの基本と近況 2611 / Local LLM basics and recent situation 2611
kishida
3
660
AIエージェントの「テストは通るのに本番で壊れる」を減らす
shibuiwilliam
3
120
Growing PicoRuby's Ecosystem on ESP32
yuuu
2
150
エラーチャンネルのボールを拾い続けて鍛えるエンジニアの地力 / phpcon-niigata2026
meihei3
1
500
선언형 햅틱 라이브러리 진동을 소개합니다
l2hyunwoo
1
330
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
17
9.5k
手の動かし方がわからなかった私が個人開発者になるまで
usagi0920_pochi
0
340
Rails初心者がパスキーを実装してみて大変だったこと
ktombow
0
240
AI時代のFlutter品質設計 — アプリ品質を守るQuality Layers
omatty198
0
390
Secure Your Coding Agent Like It’s Malware (v1.5) 🇬🇧 @Code.talks 2026
richargh
0
200
Agentic AI with the Power of Jakarta EE
ivargrimstad
0
190
Featured
See All Featured
Between Models and Reality
mayunak
4
610
Writing Fast Ruby
sferik
630
63k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
470
My Coaching Mixtape
mlcsv
0
390
Building Flexible Design Systems
yeseniaperezcruz
330
41k
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
2
570
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
490
Building Adaptive Systems
keathley
44
3.3k
Practical Orchestrator
shlominoach
192
12k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
12k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.7k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
56
3.5k