SlideShare a Scribd company logo
1 of 32
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com1
Akka-http
Open Access Quality Assurance & Related Software Development for Financial Markets
Tel: +7 495 640 2460, +1 415 830 38 49
www.exactpro.com
Дата 20.02.2017
Автор Антон Ситников
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com2
Дневник успеваемости
Понедельник
Математика
Физика
Литература 4
Физическая культура
Вторник
Русский язык 2
Математика
Английский язык 5
Технология
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com3
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com4
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Ractive.js REST / JSON
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com5
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Ractive.js REST / JSON
SQL Server
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com6
Наше приложение
Single-page
web application
ДанныеWeb-сервис
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com7
Web-сервис
HTTP backend
Сервис
данных
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com8
Web-сервис
akka-http akka JSON
HTTP backend
Сервис
данных
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com9
Сервис данных
Студенты Расписание Предметы
Оценки
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com10
01 public class ScheduleActor extends AbstractActor {
02
03 public ScheduleActor() {
04 receive(ReceiveBuilder
05 .match(SetSchedule.class,
06 command -> this.setSchedule(command.getGroupSchedules()))
07 .match(GetSchedule.class,
08 command -> this.getSchedule(command.getGroupId()))
09 .build());
10 }
11 }
ScheduleActor
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com11
01 private final Map<Integer, Schedule> groupSchedules
02 = new HashMap<>();
03
04 private void setSchedule(final List<Schedule> groupSchedules) {
05 this.groupSchedules.clear();
06 groupSchedules.forEach(schedule ->
07 this.groupSchedules.put(schedule.getGroupId(), schedule));
08 }
09
10 private void getSchedule(final int groupId) {
11 this.sender().tell(
12 this.groupSchedules.get(groupId), this.self());
13 }
14 }
ScheduleActor
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com12
SetSchedule
01 import static java.util.Collections.unmodifiableList;
02
03 public class SetSchedule {
04 private final List<Schedule> groupSchedules;
05
06 public SetSchedule(final List<Schedule> groupSchedules) {
07 this.groupSchedules = unmodifiableList(groupSchedules);
08 }
09
10 public List<Schedule> getGroupSchedules() {
11 return this.groupSchedules;
12 }
13 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com13
Данные
Студенты Расписание Предметы
Оценки
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com14
Markbook actor
MarkbookActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetSchedule
Schedule
GetSubjects
List<Subjects>
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com15
Markbook actor
MarkbookActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetStudent
Student
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com16
Child workers
Родитель
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com17
Child workers
Родитель
Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com18
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com19
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com20
Child workers
Родитель
Ребенок Ребенок
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com21
Markbook worker actor
WorkerActor StudentsActor ScheduleActor SubjectsActor
GetStudent
Student
GetSchedule
Schedule
GetSubjects
List<Subjects>
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com22
Child workers
Markbook
Worker
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com23
Markbook actor
WorkerActor StudentsActor ScheduleActor SubjectsActor
Set<Marks>
GetMarks
GetSchedule
Schedule
GetSubjects
List<Subjects>
Markbook
GetStudentMarks
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com24
Markbook worker actor
01 private static class WorkerActor extends AbstractActor {
02
03 public WorkerActor() {
04 receive(ReceiveBuilder
05 .match(GetStudentWeekMarks.class,
06 command -> this.start(
07 command.getStudentId(), command.getWeekNumber()))
08 .match(Student.class,
09 student -> this.processStudent(student))
10 .match(Schedule.class,
11 schedule -> this.processSchedule(schedule))
12 .match(SortedMap.class,
13 marks -> this.processMarks(marks))
14 .match(List.class,
15 subjects -> this.processSubjects(subjects))
16 .build());
17 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com25
Markbook worker actor
01 private void processSchedule(final Schedule schedule) {
02 this.schedule = schedule;
03 final HashSet<Integer> subjectIds = new HashSet<>();
04 schedule.getDays().forEach(
05 daySchedule -> subjectIds.addAll(daySchedule.getSubjectIds()));
06 this.context().actorSelection("/user/subjects").tell(
07 new GetSubjects(subjectIds), this.self());
08 this.context().actorSelection("..").tell(
09 new GetStudentWeekMarks(this.studentId, this.weekNumber),
10 this.self());
11 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com26
Markbook worker actor
01 private void processMarks(final SortedMap<MarkKey, Integer> marks) {
02 this.marks = marks;
03 this.replyIfReady();
04 }
05
06 private void replyIfReady() {
07 if ((this.marks != null) && (this.subjectIndex != null)) {
08 this.receiver.tell(unmodifiableList(this.getWeekMarks()),
09 this.self());
10 this.self().tell(PoisonPill.getInstance(), this.self());
11 }
12 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com27
REST API
/api/students
/api/students/studentId/marks/weekNumber
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com28
routing
01 private Route apiRoute() {
02 return pathPrefix("students", () ->
03 route(
04 rawPathPrefix(pathEnd(), () ->
05 onSuccess(() -> toJava(Patterns.ask(
06 this.studentStore, ListStudents.instance(), TIMEOUT)),
07 students -> complete(
08 StatusCodes.OK, students, Jackson.marshaller())
09 )
10 ),
11 path(
12 // ...
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com29
routing
01 path(
studentId
02 integerSegment().slash(segment("marks")
weekNumber
03 .slash(integerSegment())),
04 (studentId, weekNumber) ->
05 onSuccess(
06 () -> toJava(Patterns.ask(
07 this.markbook,
08 new GetStudentWeekMarks(studentId, weekNumber), TIMEOUT)),
09 weekMarks -> complete(
10 StatusCodes.OK, weekMarks, Jackson.marshaller())
11 )
12 )
13 )
14 );
15 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com30
routing
01 private Route appRoute() {
02 return route(
03 staticRoute(),
04 pathPrefix("api", () -> apiRoute())
05 );
06 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com31
Запуск сервера
01 private void initializeServer() {
02 final ActorMaterializer materializer
03 = ActorMaterializer.create(this.system);
04 final ConnectHttp host = ConnectHttp.toHost("127.0.0.1");
05 Http.get(this.system).bindAndHandle(
06 appRoute().flow(this.system, materializer),
07 host, materializer);
08 }
Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49
www.exactpro.com32
Спасибо

More Related Content

Similar to Akka-http

Similar to Akka-http (20)

Salesforce platform session 2
 Salesforce platform session 2 Salesforce platform session 2
Salesforce platform session 2
 
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDKLook Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
Look Ma, No Apex: Mobile Apps with RemoteObject and Mobile SDK
 
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStoreDeveloping Offline Mobile Apps with Salesforce Mobile SDK SmartStore
Developing Offline Mobile Apps with Salesforce Mobile SDK SmartStore
 
Non-Functional Testing at London Stock Exchange
Non-Functional Testing at  London Stock ExchangeNon-Functional Testing at  London Stock Exchange
Non-Functional Testing at London Stock Exchange
 
Rathna Arun Solomon_BA
Rathna Arun Solomon_BARathna Arun Solomon_BA
Rathna Arun Solomon_BA
 
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
IoTで成功を収めるための製品と戦略 〜 Salesforce IoT 〜
 
Quickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics CloudQuickly Create Data Sets for the Analytics Cloud
Quickly Create Data Sets for the Analytics Cloud
 
Exactpro: Non-functional testing approach
Exactpro: Non-functional testing approachExactpro: Non-functional testing approach
Exactpro: Non-functional testing approach
 
9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...
9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...
9 Characteristics of Agile Methodologies to Turbo-charge Your Testing by Rex ...
 
Visartech Company Profile
Visartech Company ProfileVisartech Company Profile
Visartech Company Profile
 
Silvertouch Profile
Silvertouch ProfileSilvertouch Profile
Silvertouch Profile
 
Hca advanced developer workshop
Hca advanced developer workshopHca advanced developer workshop
Hca advanced developer workshop
 
Eland: A Python client for data analysis and exploration
Eland: A Python client for data analysis and explorationEland: A Python client for data analysis and exploration
Eland: A Python client for data analysis and exploration
 
Boston 16 03
Boston 16 03Boston 16 03
Boston 16 03
 
Ortus Government.pdf
Ortus Government.pdfOrtus Government.pdf
Ortus Government.pdf
 
Introduction to the Wave Platform API
Introduction to the Wave Platform APIIntroduction to the Wave Platform API
Introduction to the Wave Platform API
 
Resume
ResumeResume
Resume
 
Nestle Quick Wins Digital Commerce Conversion Workshop
Nestle Quick Wins Digital Commerce Conversion WorkshopNestle Quick Wins Digital Commerce Conversion Workshop
Nestle Quick Wins Digital Commerce Conversion Workshop
 
From Force.com to Heroku and Back
From Force.com to Heroku and BackFrom Force.com to Heroku and Back
From Force.com to Heroku and Back
 
Introduction To Sciov1 0
Introduction To Sciov1 0Introduction To Sciov1 0
Introduction To Sciov1 0
 

More from Iosif Itkin

More from Iosif Itkin (20)

Foundations of Software Testing Lecture 4
Foundations of Software Testing Lecture 4Foundations of Software Testing Lecture 4
Foundations of Software Testing Lecture 4
 
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
QA Financial Forum London 2021 - Automation in Software Testing. Humans and C...
 
Exactpro FinTech Webinar - Global Exchanges Test Oracles
Exactpro FinTech Webinar - Global Exchanges Test OraclesExactpro FinTech Webinar - Global Exchanges Test Oracles
Exactpro FinTech Webinar - Global Exchanges Test Oracles
 
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
Exactpro FinTech Webinar - Global Exchanges FIX ProtocolExactpro FinTech Webinar - Global Exchanges FIX Protocol
Exactpro FinTech Webinar - Global Exchanges FIX Protocol
 
Operational Resilience in Financial Market Infrastructures
Operational Resilience in Financial Market InfrastructuresOperational Resilience in Financial Market Infrastructures
Operational Resilience in Financial Market Infrastructures
 
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
20 Simple Questions from Exactpro for Your Enjoyment This Holiday Season
 
Testing the Intelligence of your AI
Testing the Intelligence of your AITesting the Intelligence of your AI
Testing the Intelligence of your AI
 
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
EXTENT 2019: Exactpro Quality Assurance for Financial Market InfrastructuresEXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
EXTENT 2019: Exactpro Quality Assurance for Financial Market Infrastructures
 
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
ClearTH Test Automation Framework: Case Study in IRS & CDS Swaps Lifecycle Mo...
 
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan ShamraiEXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
EXTENT Talks 2019 Tbilisi: Failover and Recovery Test Automation - Ivan Shamrai
 
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference OpenEXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
EXTENT Talks QA Community Tbilisi 20 April 2019 - Conference Open
 
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
User-Assisted Log Analysis for Quality Control of Distributed Fintech Applica...
 
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
QAFF Chicago 2019 - Complex Post-Trade Systems, Requirements Traceability and...
 
QA Community Saratov: Past, Present, Future (2019-02-08)
QA Community Saratov: Past, Present, Future (2019-02-08)QA Community Saratov: Past, Present, Future (2019-02-08)
QA Community Saratov: Past, Present, Future (2019-02-08)
 
Machine Learning and RoboCop Testing
Machine Learning and RoboCop TestingMachine Learning and RoboCop Testing
Machine Learning and RoboCop Testing
 
Behaviour Driven Development: Oltre i limiti del possibile
Behaviour Driven Development: Oltre i limiti del possibileBehaviour Driven Development: Oltre i limiti del possibile
Behaviour Driven Development: Oltre i limiti del possibile
 
2018 - Exactpro Year in Review
2018 - Exactpro Year in Review2018 - Exactpro Year in Review
2018 - Exactpro Year in Review
 
Exactpro Discussion about Joy and Strategy
Exactpro Discussion about Joy and StrategyExactpro Discussion about Joy and Strategy
Exactpro Discussion about Joy and Strategy
 
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
FIX EMEA Conference 2018 - Post Trade Software Testing ChallengesFIX EMEA Conference 2018 - Post Trade Software Testing Challenges
FIX EMEA Conference 2018 - Post Trade Software Testing Challenges
 
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
BDD. The Outer Limits. Iosif Itkin at Youcon (in Russian)
 

Recently uploaded

IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Recently uploaded (20)

The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 

Akka-http

  • 1. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com1 Akka-http Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 2460, +1 415 830 38 49 www.exactpro.com Дата 20.02.2017 Автор Антон Ситников
  • 2. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com2 Дневник успеваемости Понедельник Математика Физика Литература 4 Физическая культура Вторник Русский язык 2 Математика Английский язык 5 Технология
  • 3. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com3 Наше приложение Single-page web application ДанныеWeb-сервис
  • 4. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com4 Наше приложение Single-page web application ДанныеWeb-сервис Ractive.js REST / JSON
  • 5. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com5 Наше приложение Single-page web application ДанныеWeb-сервис Ractive.js REST / JSON SQL Server
  • 6. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com6 Наше приложение Single-page web application ДанныеWeb-сервис
  • 7. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com7 Web-сервис HTTP backend Сервис данных
  • 8. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com8 Web-сервис akka-http akka JSON HTTP backend Сервис данных
  • 9. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com9 Сервис данных Студенты Расписание Предметы Оценки
  • 10. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com10 01 public class ScheduleActor extends AbstractActor { 02 03 public ScheduleActor() { 04 receive(ReceiveBuilder 05 .match(SetSchedule.class, 06 command -> this.setSchedule(command.getGroupSchedules())) 07 .match(GetSchedule.class, 08 command -> this.getSchedule(command.getGroupId())) 09 .build()); 10 } 11 } ScheduleActor
  • 11. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com11 01 private final Map<Integer, Schedule> groupSchedules 02 = new HashMap<>(); 03 04 private void setSchedule(final List<Schedule> groupSchedules) { 05 this.groupSchedules.clear(); 06 groupSchedules.forEach(schedule -> 07 this.groupSchedules.put(schedule.getGroupId(), schedule)); 08 } 09 10 private void getSchedule(final int groupId) { 11 this.sender().tell( 12 this.groupSchedules.get(groupId), this.self()); 13 } 14 } ScheduleActor
  • 12. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com12 SetSchedule 01 import static java.util.Collections.unmodifiableList; 02 03 public class SetSchedule { 04 private final List<Schedule> groupSchedules; 05 06 public SetSchedule(final List<Schedule> groupSchedules) { 07 this.groupSchedules = unmodifiableList(groupSchedules); 08 } 09 10 public List<Schedule> getGroupSchedules() { 11 return this.groupSchedules; 12 } 13 }
  • 13. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com13 Данные Студенты Расписание Предметы Оценки
  • 14. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com14 Markbook actor MarkbookActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetSchedule Schedule GetSubjects List<Subjects>
  • 15. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com15 Markbook actor MarkbookActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetStudent Student
  • 16. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com16 Child workers Родитель
  • 17. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com17 Child workers Родитель Ребенок
  • 18. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com18 Child workers Родитель Ребенок Ребенок
  • 19. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com19 Child workers Родитель Ребенок Ребенок
  • 20. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com20 Child workers Родитель Ребенок Ребенок
  • 21. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com21 Markbook worker actor WorkerActor StudentsActor ScheduleActor SubjectsActor GetStudent Student GetSchedule Schedule GetSubjects List<Subjects>
  • 22. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com22 Child workers Markbook Worker
  • 23. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com23 Markbook actor WorkerActor StudentsActor ScheduleActor SubjectsActor Set<Marks> GetMarks GetSchedule Schedule GetSubjects List<Subjects> Markbook GetStudentMarks
  • 24. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com24 Markbook worker actor 01 private static class WorkerActor extends AbstractActor { 02 03 public WorkerActor() { 04 receive(ReceiveBuilder 05 .match(GetStudentWeekMarks.class, 06 command -> this.start( 07 command.getStudentId(), command.getWeekNumber())) 08 .match(Student.class, 09 student -> this.processStudent(student)) 10 .match(Schedule.class, 11 schedule -> this.processSchedule(schedule)) 12 .match(SortedMap.class, 13 marks -> this.processMarks(marks)) 14 .match(List.class, 15 subjects -> this.processSubjects(subjects)) 16 .build()); 17 }
  • 25. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com25 Markbook worker actor 01 private void processSchedule(final Schedule schedule) { 02 this.schedule = schedule; 03 final HashSet<Integer> subjectIds = new HashSet<>(); 04 schedule.getDays().forEach( 05 daySchedule -> subjectIds.addAll(daySchedule.getSubjectIds())); 06 this.context().actorSelection("/user/subjects").tell( 07 new GetSubjects(subjectIds), this.self()); 08 this.context().actorSelection("..").tell( 09 new GetStudentWeekMarks(this.studentId, this.weekNumber), 10 this.self()); 11 }
  • 26. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com26 Markbook worker actor 01 private void processMarks(final SortedMap<MarkKey, Integer> marks) { 02 this.marks = marks; 03 this.replyIfReady(); 04 } 05 06 private void replyIfReady() { 07 if ((this.marks != null) && (this.subjectIndex != null)) { 08 this.receiver.tell(unmodifiableList(this.getWeekMarks()), 09 this.self()); 10 this.self().tell(PoisonPill.getInstance(), this.self()); 11 } 12 }
  • 27. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com27 REST API /api/students /api/students/studentId/marks/weekNumber
  • 28. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com28 routing 01 private Route apiRoute() { 02 return pathPrefix("students", () -> 03 route( 04 rawPathPrefix(pathEnd(), () -> 05 onSuccess(() -> toJava(Patterns.ask( 06 this.studentStore, ListStudents.instance(), TIMEOUT)), 07 students -> complete( 08 StatusCodes.OK, students, Jackson.marshaller()) 09 ) 10 ), 11 path( 12 // ...
  • 29. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com29 routing 01 path( studentId 02 integerSegment().slash(segment("marks") weekNumber 03 .slash(integerSegment())), 04 (studentId, weekNumber) -> 05 onSuccess( 06 () -> toJava(Patterns.ask( 07 this.markbook, 08 new GetStudentWeekMarks(studentId, weekNumber), TIMEOUT)), 09 weekMarks -> complete( 10 StatusCodes.OK, weekMarks, Jackson.marshaller()) 11 ) 12 ) 13 ) 14 ); 15 }
  • 30. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com30 routing 01 private Route appRoute() { 02 return route( 03 staticRoute(), 04 pathPrefix("api", () -> apiRoute()) 05 ); 06 }
  • 31. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com31 Запуск сервера 01 private void initializeServer() { 02 final ActorMaterializer materializer 03 = ActorMaterializer.create(this.system); 04 final ConnectHttp host = ConnectHttp.toHost("127.0.0.1"); 05 Http.get(this.system).bindAndHandle( 06 appRoute().flow(this.system, materializer), 07 host, materializer); 08 }
  • 32. Open Access Quality Assurance & Related Software Development for Financial Markets Tel: +7 495 640 24 60 , +1 415 830 38 49 www.exactpro.com32 Спасибо