Slides from my talk at Elixir Club 11 Meetup in Ternopil, 2018.
In my talk I want to share with some real world experience about problems that we faced while implementing one of the eHealth services, what steps were taken iteratively, what gotchas we faced in the process and how GenServer was used make application more reliable and responsible.
The document introduces asynchronous programming and coroutines. It discusses:
1. The evolution of input/output loops from blocking to asynchronous models using callbacks and futures. Examples include Twisted, Tornado, Tkinter.
2. How futures/promises allow adding callbacks to be notified of results asynchronously, avoiding blocking. Examples shown in JavaScript, Twisted, asyncio.
3. Key aspects of coroutines like yielding and awaiting futures to resume execution asynchronously. Rules for writing asyncio coroutines in Python are provided.
4. Asynchronous programming allows concurrent execution without blocking, improving responsiveness through asynchronous callbacks and coroutines.
The Ring programming language version 1.3 book - Part 59 of 88Mahmoud Samir Fayed
The document provides details about printing the final intermediate code generated after executing a Ring program.
It begins by showing the output of running a test Ring program and printing the bytecode. This includes the byte code instructions, operation codes, program counter, data, and other details.
It then shows sections of the large intermediate code output, including function and method definitions, variable assignments, calls between functions, and other low-level operations.
The document explains that the output provides a detailed view of the final bytecode generated from the Ring source code after it has been executed by the Ring virtual machine. This allows viewing and understanding the low-level operations performed during program execution.
The Ring programming language version 1.5.2 book - Part 74 of 181Mahmoud Samir Fayed
This document provides information about low level functions in Ring that allow interaction with C code and pointers. It describes the following functions:
- callgc() forces garbage collection to free temporary variables
- varptr() gets a C pointer for a Ring variable
- space() allocates memory and returns a string pointer
- nullpointer() returns a NULL pointer for optional parameters
- object2pointer() gets a C pointer for a Ring list or object
- pointer2object() converts a C pointer back to a Ring list or object
- ptrcmp() compares two C pointers
It also briefly mentions ringvm functions for getting information about the runtime environment like loaded classes, functions, memory usage and more.
The Ring programming language version 1.4 book - Part 21 of 30Mahmoud Samir Fayed
This document provides information about low level functions in Ring that interface with C and the Ring virtual machine. It discusses the callgc() function to manually call the garbage collector, the varptr() function to get a pointer to a C variable, the space() function to allocate memory, nullpointer() to pass a null pointer, object2pointer() and pointer2object() to convert between Ring objects and C pointers, ptrcmp() to compare pointers, and functions like ringvm_cfunctionslist() to get lists of C functions and ringvm_functionslist() to get a list of Ring functions from the bytecode. These low level functions provide interfaces between Ring and C to integrate Ring with C libraries and code.
The Ring programming language version 1.5.4 book - Part 69 of 185Mahmoud Samir Fayed
This document describes a simple cards game application developed using RingQt. Each player is dealt 5 cards face down. Players take turns clicking cards to reveal them. If a card matches another visible card or is a 5, the player earns points and "eats" the matching cards. The first player to earn more points than their opponent wins. The application initializes card data, displays buttons for each card, and handles click events to reveal cards and check for matches and winners. Functions are used to delay actions, update scores and buttons, and start a new game once all cards are revealed.
The Ring programming language version 1.5.1 book - Part 65 of 180Mahmoud Samir Fayed
This document describes a cards game application developed using the Ring programming language and Qt GUI library. The application deals 5 cards to each of two players. When a player clicks on a card, it is revealed. If the card matches another revealed card, the player scores a point for each matching card. If the card is a "5", the player scores for all revealed cards. The application tracks each player's score, handles clicking cards to reveal them, and checks for matches or a "5" to score points. It also includes functionality to start a new game and close the application.
The document describes how to build a fantasy football team manager application in Erlang. It first shows an implementation using plain processes and message passing to manage adding and removing players from a team. It then shows how to implement the same functionality using the GenServer behavior to provide a more robust API. The GenServer implementation stores the team state internally and provides functions to add, remove, and retrieve the team via callbacks that handle state updates and replies.
The Ring programming language version 1.7 book - Part 93 of 196Mahmoud Samir Fayed
The document provides reference documentation for the RingQt classes CodeEditor, QAbstractButton, and QAbstractItemView.
It lists the parameters, parent classes, and methods for each class. For CodeEditor it describes methods related to autocompletion and styling line numbers. For QAbstractButton it describes methods for buttons like checking/unchecking and setting icons/text. For QAbstractItemView it describes methods for item views like selecting indexes, drag/drop, and delegates.
The document introduces asynchronous programming and coroutines. It discusses:
1. The evolution of input/output loops from blocking to asynchronous models using callbacks and futures. Examples include Twisted, Tornado, Tkinter.
2. How futures/promises allow adding callbacks to be notified of results asynchronously, avoiding blocking. Examples shown in JavaScript, Twisted, asyncio.
3. Key aspects of coroutines like yielding and awaiting futures to resume execution asynchronously. Rules for writing asyncio coroutines in Python are provided.
4. Asynchronous programming allows concurrent execution without blocking, improving responsiveness through asynchronous callbacks and coroutines.
The Ring programming language version 1.3 book - Part 59 of 88Mahmoud Samir Fayed
The document provides details about printing the final intermediate code generated after executing a Ring program.
It begins by showing the output of running a test Ring program and printing the bytecode. This includes the byte code instructions, operation codes, program counter, data, and other details.
It then shows sections of the large intermediate code output, including function and method definitions, variable assignments, calls between functions, and other low-level operations.
The document explains that the output provides a detailed view of the final bytecode generated from the Ring source code after it has been executed by the Ring virtual machine. This allows viewing and understanding the low-level operations performed during program execution.
The Ring programming language version 1.5.2 book - Part 74 of 181Mahmoud Samir Fayed
This document provides information about low level functions in Ring that allow interaction with C code and pointers. It describes the following functions:
- callgc() forces garbage collection to free temporary variables
- varptr() gets a C pointer for a Ring variable
- space() allocates memory and returns a string pointer
- nullpointer() returns a NULL pointer for optional parameters
- object2pointer() gets a C pointer for a Ring list or object
- pointer2object() converts a C pointer back to a Ring list or object
- ptrcmp() compares two C pointers
It also briefly mentions ringvm functions for getting information about the runtime environment like loaded classes, functions, memory usage and more.
The Ring programming language version 1.4 book - Part 21 of 30Mahmoud Samir Fayed
This document provides information about low level functions in Ring that interface with C and the Ring virtual machine. It discusses the callgc() function to manually call the garbage collector, the varptr() function to get a pointer to a C variable, the space() function to allocate memory, nullpointer() to pass a null pointer, object2pointer() and pointer2object() to convert between Ring objects and C pointers, ptrcmp() to compare pointers, and functions like ringvm_cfunctionslist() to get lists of C functions and ringvm_functionslist() to get a list of Ring functions from the bytecode. These low level functions provide interfaces between Ring and C to integrate Ring with C libraries and code.
The Ring programming language version 1.5.4 book - Part 69 of 185Mahmoud Samir Fayed
This document describes a simple cards game application developed using RingQt. Each player is dealt 5 cards face down. Players take turns clicking cards to reveal them. If a card matches another visible card or is a 5, the player earns points and "eats" the matching cards. The first player to earn more points than their opponent wins. The application initializes card data, displays buttons for each card, and handles click events to reveal cards and check for matches and winners. Functions are used to delay actions, update scores and buttons, and start a new game once all cards are revealed.
The Ring programming language version 1.5.1 book - Part 65 of 180Mahmoud Samir Fayed
This document describes a cards game application developed using the Ring programming language and Qt GUI library. The application deals 5 cards to each of two players. When a player clicks on a card, it is revealed. If the card matches another revealed card, the player scores a point for each matching card. If the card is a "5", the player scores for all revealed cards. The application tracks each player's score, handles clicking cards to reveal them, and checks for matches or a "5" to score points. It also includes functionality to start a new game and close the application.
The document describes how to build a fantasy football team manager application in Erlang. It first shows an implementation using plain processes and message passing to manage adding and removing players from a team. It then shows how to implement the same functionality using the GenServer behavior to provide a more robust API. The GenServer implementation stores the team state internally and provides functions to add, remove, and retrieve the team via callbacks that handle state updates and replies.
The Ring programming language version 1.7 book - Part 93 of 196Mahmoud Samir Fayed
The document provides reference documentation for the RingQt classes CodeEditor, QAbstractButton, and QAbstractItemView.
It lists the parameters, parent classes, and methods for each class. For CodeEditor it describes methods related to autocompletion and styling line numbers. For QAbstractButton it describes methods for buttons like checking/unchecking and setting icons/text. For QAbstractItemView it describes methods for item views like selecting indexes, drag/drop, and delegates.
The Ring programming language version 1.5.3 book - Part 19 of 194Mahmoud Samir Fayed
The document provides the language grammar for Ring, including statements, expressions, and virtual machine instructions. It defines statements like package, class, func, if/else, for/in loops, and expressions involving operators, comparisons, math, logic, lists, and functions. The virtual machine section describes over 70 instructions for operations on the stack, variables, functions, comparisons, math, logic, lists, control flow, and more.
The Ring programming language version 1.6 book - Part 71 of 189Mahmoud Samir Fayed
This document describes a cards game developed using the Ring programming language and Qt GUI library. The game has two players who take turns flipping over cards from a deck to try and match cards or get a "5" card to earn points. The application initializes a deck of cards, displays the cards face down for each player, and includes functions for players to click cards to flip them over. It tracks the game state, scores, and allows starting a new game. Key aspects include initializing the deck randomly, checking for matches or "5" cards when clicked, and updating the game state and scores accordingly.
The Ring programming language version 1.6 book - Part 55 of 189Mahmoud Samir Fayed
Here are the key points about RingOpenGL:
- RingOpenGL provides bindings to the OpenGL graphics library, allowing Ring programs to use 3D graphics capabilities.
- It supports multiple versions of OpenGL from 1.1 to the latest 4.3 specification. This allows access to modern OpenGL features.
- Sample programs are included to demonstrate basic 3D rendering concepts like drawing cubes, handling user input, etc. These are based on tutorials for the GLUT (OpenGL Utility Toolkit) library.
- To get started, programs can load the RingOpenGL library and make OpenGL calls like glBegin, glColor3f, glVertex3f to render 3D shapes and scenes.
- The RingFreeGLUT
In this talk we will look at some of the optimizations that JavaScriptCore uses to speed up JavaScript execution, and perhaps counterintuitively, how the same optimizations are also being applied to speeding up WebAssembly.
The Ring programming language version 1.10 book - Part 89 of 212Mahmoud Samir Fayed
1. Use efficient data structures like arrays instead of lists when possible.
2. Optimize algorithms to have better time complexity.
3. Use C/C++ extensions for performance critical parts of code.
4. Profile code to identify bottlenecks and areas for optimization.
The Ring programming language version 1.8 book - Part 84 of 202Mahmoud Samir Fayed
This document discusses various performance tips for Ring programs:
1. Ring is designed for simplicity but can still perform many common tasks in around 1 second on modern hardware. C extensions can further improve performance.
2. Creating lists using the range operator is faster than a for loop or list() function. Using *= is faster than * for arithmetic.
3. Calling len() before a for loop is faster than within. Calling functions is slightly faster than methods, and the dot operator is faster than braces for methods.
A discussion of Erlang/OTP, based on the "A History of Erlang" paper, with the addition of covering some of the methods used in the paper that enable Riak to be a highly reliable, distributed datastore, while leveraging the work of giants.
The Ring programming language version 1.5.2 book - Part 26 of 181Mahmoud Samir Fayed
This document provides examples and documentation for various Ring programming language functions related to input/output, file handling, debugging, and creating demo programs. It describes functions for getting command line arguments, the active source file name, changing directories, and more. It also covers try/catch error handling, the eval() function for executing code as a string, and assert() for validating conditions. Finally, it presents two demo programs - an interactive shell and a menu-driven program - to demonstrate basic Ring concepts.
This document discusses environments and scoping in R. It provides examples of how parent environments and parent frames work when calling functions. The key points are:
- The parent environment of a function is the environment in which the function is defined.
- The parent frame of a function is the environment from which the function was called.
- Variables in the parent environments and frames may be accessible depending on the context.
This document discusses the R debugger. It provides examples of using the browser(), debug(), and debugonce() functions to debug R code. The browser allows stepping through code line-by-line and examining variable values. debug() and debugonce() activate debugging for a function. Other debugging topics covered include traceback(), browserText(), and examining the coefficients of linear models.
The Ring programming language version 1.4 book - Part 18 of 30Mahmoud Samir Fayed
This document provides code for a simple notepad application created using the Ring programming language and Qt GUI library. The application allows users to open, edit, save, print, find/replace, and run Ring code files. It includes menus, toolbars, and buttons for common editing functions and uses classes like QTextEdit, QFile, and QPrinter. The application stores settings for the active file name, text colors, font, and handles events for opening, saving, printing and running files.
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQAFest
Our daily work is comprised of testing a product and improve its quality. However, here and there, we can come to a state where we find a need to build a tool, that can make our work easierbetter.
I will share from my experience when I found myself in a situation where building a tool was needed.
We will start with a web application that allows you to know when a food delivery you ordered arrives to the office, and then we will focus on a tool that test the performance of an app from the UI side. We will do a live demo for both of them.
The Ring programming language version 1.9 book - Part 48 of 210Mahmoud Samir Fayed
The document discusses using the Natural library in Ring to define a domain-specific language for natural language commands. It provides an example program that:
1) Loads the Natural library and defines a new NaturalLanguage class to set up the language name, commands path, and package name.
2) Defines two sample commands - Hello and Count - in separate files that are called by the language.
3) Runs a sample natural language program file containing usages of those commands and outputs the results.
4) Explains how to define new commands using the DefineNaturalCommand object's syntax methods, and provides examples of different command syntax definitions.
5) Optionally allows setting operators to enclose commands for a L
This document contains code snippets for 12 common C++ programs: 1) checking if a number is even or odd, 2) swapping two numbers, 3) checking if a year is a leap year, 4) sorting words in dictionary order, 5) calculating a factorial, 6) generating a Fibonacci series, 7) transposing a matrix, 8) using constructors and destructors, 9) demonstrating multiple inheritance, 10) using static members and functions, 11) exception handling, and 12) file input/output. Each code snippet is followed by sample input/output to demonstrate the program's functionality.
This document provides tips and tricks for installing Kotlin programming tools and covers fundamental Kotlin concepts like data types, variables, functions, control flow structures, and loops. It discusses installing Kotlin and resolving common errors. It introduces basic Kotlin syntax for strings, numbers, Booleans, arrays, and more. It also covers if/else expressions, when expressions, enums, loops like while, for, and for-each, and break/continue functionality. The document encourages practicing exercises to continue learning Kotlin.
The Ring programming language version 1.6 book - Part 15 of 189Mahmoud Samir Fayed
The document summarizes the new features and changes in Ring 1.2, including:
1. New functions like PtrCmp(), PrevFileName(), and functions to retrieve lists of functions, classes, packages, etc.
2. Improved existing functions like find() and type() to support C pointers.
3. Enhancements to Ring Notepad and RingQt like line number restoration and event handling.
4. The introduction of an Objects library for RingQt and better support for the MVC pattern.
5. The RingLibCurl library providing an API for the libcurl functions.
6. Updates to call handling and allowing NULL instead of NULLPointer().
The Ring programming language version 1.2 book - Part 16 of 84Mahmoud Samir Fayed
The document describes various functions in Ring for determining operating system and environment details. It explains functions like IsMacOSX(), IsLinux(), IsFreeBSD(), IsAndroid() that return 1 if the OS is the given one, and 0 otherwise. It also presents functions for getting command line arguments (sysargv), active source file name (filename()), Windows/Linux newline characters (Windowsnl()), current directory (CurrentDir()), Ring executable path (exefolder()), Ring version (version()), and changing directory (ChDir()). Examples are given to demonstrate the usage of these functions.
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
The document describes the Trace Library in Ring and how it can be used to trace program execution, debug code, and step through a program line by line. It provides examples of loading the Trace Library, tracing all events, tracing control flow between functions, and using the pass error functionality to continue execution after an error. Key functions and capabilities of the Trace Library discussed include tracing specific events, setting breakpoints, accessing trace data, and redefining see and give behavior.
The Ring programming language version 1.5.3 book - Part 25 of 184Mahmoud Samir Fayed
This document provides summaries of various file handling functions in Ring programming language including Read(), Write(), Dir(), Rename(), Remove(), fopen(), fclose(), fflush(), freopen(), tempfile(), tempname(), fseek(), ftell(), rewind(), fgetpos(), fsetpos(), clearerr(), feof(), ferror(), perror(), fgetc(), fgets(), fputc(), fputs(), ungetc(), fread(), fwrite(), fexists(), and describes how to use numbers and bytes with files. Examples are given to demonstrate the use of these functions for tasks like reading and writing files, getting directory listings, opening and closing files, seeking within files, and checking for errors.
The Ring programming language version 1.7 book - Part 16 of 196Mahmoud Samir Fayed
This document summarizes the new features and changes in Ring 1.2, including new functions like PtrCmp() and PrevFileName(), improved functions like find() supporting C pointers, an improved Ring Notepad that saves line numbers, better RingQt classes with event handling, a new Objects library for RingQt, an enhanced RingLibCurl library, improved call command support, using NULL instead of NULLPointer(), a new display warnings option, and general quality improvements.
This document discusses using Gevent and RabbitMQ for asynchronous RPC. It describes some limitations of Celery and how Gevent can help overcome them. Gevent is a coroutine-based Python library that uses greenlets to provide asynchronous I/O. RabbitMQ is a message broker that can be used for asynchronous RPC. The document proposes a model for asynchronous RPC using Gevent, RabbitMQ, and greenlets. It provides examples of building applications using this approach, including dispatching tasks and handling results.
Elixir -Tolerância a Falhas para Adultos - GDG CampinasFabio Akita
Tolerância a Falhas para Adultos is a document about Elixir and distributed processing in 3 sentences or less:
It discusses concepts in Elixir like processes, message passing, and supervision trees to provide fault tolerance. It also covers distributing processing using libraries like Flow to partition and process large datasets across multiple nodes. The document provides an overview of key Elixir concepts for building distributed and fault tolerant applications.
The Ring programming language version 1.5.3 book - Part 19 of 194Mahmoud Samir Fayed
The document provides the language grammar for Ring, including statements, expressions, and virtual machine instructions. It defines statements like package, class, func, if/else, for/in loops, and expressions involving operators, comparisons, math, logic, lists, and functions. The virtual machine section describes over 70 instructions for operations on the stack, variables, functions, comparisons, math, logic, lists, control flow, and more.
The Ring programming language version 1.6 book - Part 71 of 189Mahmoud Samir Fayed
This document describes a cards game developed using the Ring programming language and Qt GUI library. The game has two players who take turns flipping over cards from a deck to try and match cards or get a "5" card to earn points. The application initializes a deck of cards, displays the cards face down for each player, and includes functions for players to click cards to flip them over. It tracks the game state, scores, and allows starting a new game. Key aspects include initializing the deck randomly, checking for matches or "5" cards when clicked, and updating the game state and scores accordingly.
The Ring programming language version 1.6 book - Part 55 of 189Mahmoud Samir Fayed
Here are the key points about RingOpenGL:
- RingOpenGL provides bindings to the OpenGL graphics library, allowing Ring programs to use 3D graphics capabilities.
- It supports multiple versions of OpenGL from 1.1 to the latest 4.3 specification. This allows access to modern OpenGL features.
- Sample programs are included to demonstrate basic 3D rendering concepts like drawing cubes, handling user input, etc. These are based on tutorials for the GLUT (OpenGL Utility Toolkit) library.
- To get started, programs can load the RingOpenGL library and make OpenGL calls like glBegin, glColor3f, glVertex3f to render 3D shapes and scenes.
- The RingFreeGLUT
In this talk we will look at some of the optimizations that JavaScriptCore uses to speed up JavaScript execution, and perhaps counterintuitively, how the same optimizations are also being applied to speeding up WebAssembly.
The Ring programming language version 1.10 book - Part 89 of 212Mahmoud Samir Fayed
1. Use efficient data structures like arrays instead of lists when possible.
2. Optimize algorithms to have better time complexity.
3. Use C/C++ extensions for performance critical parts of code.
4. Profile code to identify bottlenecks and areas for optimization.
The Ring programming language version 1.8 book - Part 84 of 202Mahmoud Samir Fayed
This document discusses various performance tips for Ring programs:
1. Ring is designed for simplicity but can still perform many common tasks in around 1 second on modern hardware. C extensions can further improve performance.
2. Creating lists using the range operator is faster than a for loop or list() function. Using *= is faster than * for arithmetic.
3. Calling len() before a for loop is faster than within. Calling functions is slightly faster than methods, and the dot operator is faster than braces for methods.
A discussion of Erlang/OTP, based on the "A History of Erlang" paper, with the addition of covering some of the methods used in the paper that enable Riak to be a highly reliable, distributed datastore, while leveraging the work of giants.
The Ring programming language version 1.5.2 book - Part 26 of 181Mahmoud Samir Fayed
This document provides examples and documentation for various Ring programming language functions related to input/output, file handling, debugging, and creating demo programs. It describes functions for getting command line arguments, the active source file name, changing directories, and more. It also covers try/catch error handling, the eval() function for executing code as a string, and assert() for validating conditions. Finally, it presents two demo programs - an interactive shell and a menu-driven program - to demonstrate basic Ring concepts.
This document discusses environments and scoping in R. It provides examples of how parent environments and parent frames work when calling functions. The key points are:
- The parent environment of a function is the environment in which the function is defined.
- The parent frame of a function is the environment from which the function was called.
- Variables in the parent environments and frames may be accessible depending on the context.
This document discusses the R debugger. It provides examples of using the browser(), debug(), and debugonce() functions to debug R code. The browser allows stepping through code line-by-line and examining variable values. debug() and debugonce() activate debugging for a function. Other debugging topics covered include traceback(), browserText(), and examining the coefficients of linear models.
The Ring programming language version 1.4 book - Part 18 of 30Mahmoud Samir Fayed
This document provides code for a simple notepad application created using the Ring programming language and Qt GUI library. The application allows users to open, edit, save, print, find/replace, and run Ring code files. It includes menus, toolbars, and buttons for common editing functions and uses classes like QTextEdit, QFile, and QPrinter. The application stores settings for the active file name, text colors, font, and handles events for opening, saving, printing and running files.
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQAFest
Our daily work is comprised of testing a product and improve its quality. However, here and there, we can come to a state where we find a need to build a tool, that can make our work easierbetter.
I will share from my experience when I found myself in a situation where building a tool was needed.
We will start with a web application that allows you to know when a food delivery you ordered arrives to the office, and then we will focus on a tool that test the performance of an app from the UI side. We will do a live demo for both of them.
The Ring programming language version 1.9 book - Part 48 of 210Mahmoud Samir Fayed
The document discusses using the Natural library in Ring to define a domain-specific language for natural language commands. It provides an example program that:
1) Loads the Natural library and defines a new NaturalLanguage class to set up the language name, commands path, and package name.
2) Defines two sample commands - Hello and Count - in separate files that are called by the language.
3) Runs a sample natural language program file containing usages of those commands and outputs the results.
4) Explains how to define new commands using the DefineNaturalCommand object's syntax methods, and provides examples of different command syntax definitions.
5) Optionally allows setting operators to enclose commands for a L
This document contains code snippets for 12 common C++ programs: 1) checking if a number is even or odd, 2) swapping two numbers, 3) checking if a year is a leap year, 4) sorting words in dictionary order, 5) calculating a factorial, 6) generating a Fibonacci series, 7) transposing a matrix, 8) using constructors and destructors, 9) demonstrating multiple inheritance, 10) using static members and functions, 11) exception handling, and 12) file input/output. Each code snippet is followed by sample input/output to demonstrate the program's functionality.
This document provides tips and tricks for installing Kotlin programming tools and covers fundamental Kotlin concepts like data types, variables, functions, control flow structures, and loops. It discusses installing Kotlin and resolving common errors. It introduces basic Kotlin syntax for strings, numbers, Booleans, arrays, and more. It also covers if/else expressions, when expressions, enums, loops like while, for, and for-each, and break/continue functionality. The document encourages practicing exercises to continue learning Kotlin.
The Ring programming language version 1.6 book - Part 15 of 189Mahmoud Samir Fayed
The document summarizes the new features and changes in Ring 1.2, including:
1. New functions like PtrCmp(), PrevFileName(), and functions to retrieve lists of functions, classes, packages, etc.
2. Improved existing functions like find() and type() to support C pointers.
3. Enhancements to Ring Notepad and RingQt like line number restoration and event handling.
4. The introduction of an Objects library for RingQt and better support for the MVC pattern.
5. The RingLibCurl library providing an API for the libcurl functions.
6. Updates to call handling and allowing NULL instead of NULLPointer().
The Ring programming language version 1.2 book - Part 16 of 84Mahmoud Samir Fayed
The document describes various functions in Ring for determining operating system and environment details. It explains functions like IsMacOSX(), IsLinux(), IsFreeBSD(), IsAndroid() that return 1 if the OS is the given one, and 0 otherwise. It also presents functions for getting command line arguments (sysargv), active source file name (filename()), Windows/Linux newline characters (Windowsnl()), current directory (CurrentDir()), Ring executable path (exefolder()), Ring version (version()), and changing directory (ChDir()). Examples are given to demonstrate the usage of these functions.
The Ring programming language version 1.10 book - Part 94 of 212Mahmoud Samir Fayed
The document describes the Trace Library in Ring and how it can be used to trace program execution, debug code, and step through a program line by line. It provides examples of loading the Trace Library, tracing all events, tracing control flow between functions, and using the pass error functionality to continue execution after an error. Key functions and capabilities of the Trace Library discussed include tracing specific events, setting breakpoints, accessing trace data, and redefining see and give behavior.
The Ring programming language version 1.5.3 book - Part 25 of 184Mahmoud Samir Fayed
This document provides summaries of various file handling functions in Ring programming language including Read(), Write(), Dir(), Rename(), Remove(), fopen(), fclose(), fflush(), freopen(), tempfile(), tempname(), fseek(), ftell(), rewind(), fgetpos(), fsetpos(), clearerr(), feof(), ferror(), perror(), fgetc(), fgets(), fputc(), fputs(), ungetc(), fread(), fwrite(), fexists(), and describes how to use numbers and bytes with files. Examples are given to demonstrate the use of these functions for tasks like reading and writing files, getting directory listings, opening and closing files, seeking within files, and checking for errors.
The Ring programming language version 1.7 book - Part 16 of 196Mahmoud Samir Fayed
This document summarizes the new features and changes in Ring 1.2, including new functions like PtrCmp() and PrevFileName(), improved functions like find() supporting C pointers, an improved Ring Notepad that saves line numbers, better RingQt classes with event handling, a new Objects library for RingQt, an enhanced RingLibCurl library, improved call command support, using NULL instead of NULLPointer(), a new display warnings option, and general quality improvements.
This document discusses using Gevent and RabbitMQ for asynchronous RPC. It describes some limitations of Celery and how Gevent can help overcome them. Gevent is a coroutine-based Python library that uses greenlets to provide asynchronous I/O. RabbitMQ is a message broker that can be used for asynchronous RPC. The document proposes a model for asynchronous RPC using Gevent, RabbitMQ, and greenlets. It provides examples of building applications using this approach, including dispatching tasks and handling results.
Elixir -Tolerância a Falhas para Adultos - GDG CampinasFabio Akita
Tolerância a Falhas para Adultos is a document about Elixir and distributed processing in 3 sentences or less:
It discusses concepts in Elixir like processes, message passing, and supervision trees to provide fault tolerance. It also covers distributing processing using libraries like Flow to partition and process large datasets across multiple nodes. The document provides an overview of key Elixir concepts for building distributed and fault tolerant applications.
Elixir is a functional programming language that is well-suited for building scalable and fault-tolerant applications. The document provides an introduction to Elixir by discussing its roots in Erlang and how it builds upon Erlang's strengths like concurrency, distribution, and fault tolerance. It also demonstrates some basic Elixir concepts like functions, pattern matching, recursion, and the BEAM virtual machine. Finally, it provides examples of real-world applications of Elixir like building Phoenix web applications and developing embedded hardware projects with Nerves.
The document summarizes various Python profiling tools. It discusses using the time utility and time module to measure elapsed time. It also covers the profile, cProfile, hotshot, lineprofiler, memoryprofiler, and objgraph modules for profiling code performance and memory usage. Examples are given showing how each tool can be used and the type of output it provides.
Gevent is a concurrency library for Python that uses greenlets, or lightweight coroutines, to provide asynchronous operations and non-blocking I/O. It allows developing highly concurrent applications using a simple and familiar synchronous style. The document discusses gevent's use of greenlets, event loops, asynchronous execution, and how it provides solutions for common issues like callback hell, non-determinism, and blocking calls. It also compares gevent to other asynchronous frameworks like asyncio and highlights how both use coroutines and scheduling to enable concurrent behaviors.
«Gevent — быть или не быть?» Александр Мокров, Positive Technologiesit-people
Gevent is a concurrency library for Python that uses greenlets, or lightweight coroutines, to provide asynchronous operations and non-blocking I/O. It allows developing highly concurrent applications using a simple and familiar synchronous style. The document compares gevent to other concurrency options like asyncio and discusses how it provides features like asynchronous task execution, event loops, and inter-greenlet communication using queues and callbacks.
Celery is an open source asynchronous task queue/job queue based on distributed message passing. It allows tasks to be executed concurrently, in the background across multiple servers. Common use cases include running long tasks like API calls or image processing without blocking the main process, load balancing tasks across servers, and concurrent execution of batch jobs. Celery uses message brokers like RabbitMQ to asynchronously queue and schedule tasks. Tasks are defined as Python functions which get executed by worker processes. The workflow involves defining tasks, adding tasks to the queue from views or management commands, and having workers process the tasks.
The document contains code snippets demonstrating inter-process communication (IPC) techniques in Unix/Linux like message queues, pipes, semaphores, and shared memory. It includes examples of message passing between processes using message queues and pipes. It also shows implementations of wait/signal and counting semaphores. The last part demonstrates solving the producer-consumer problem using shared memory and semaphores with a limited buffer size.
Part 3-functions1-120315220356-phpapp01Abdul Samee
The document provides information about functions in C++. It defines what a function is, how functions are called and defined. It discusses function parameters, return types, and function prototypes. It covers local and global variables, call by value vs call by reference, and recursion. It also discusses function overloading, where multiple functions can have the same name but different parameters.
Think Async: Asynchronous Patterns in NodeJSAdam L Barrett
JavaScript is single threaded, so understanding the async patterns available in the language is critical to creating maintainable NodeJS applications with good performance. In order to master “thinking in async”, we’ll explore the async patterns available in node and JavaScript including standard callbacks, promises, thunks/tasks, the new async/await, the upcoming asynchronous iteration features, streams, CSP and ES Observables.
Wiktor Toporek: Pomimo tego że JavaScript mocno ewoluował na przestrzeni ostatnich lat, zakorzeniona w nim jego asynchroniczna natura wciąż może sprawiać problem programistom i to zarówno początkującym jak i tym zaawansowanym. W prezentacji przyjrzymy się jednemu z bohaterów programowania asynchronicznego jakim jest Promise, przeanalizujemy niektóre z pułapek oraz zastanowimy się również czy w pełni wykorzystujemy jego potencjał.
This document provides examples of built-in functions and decorators in Python like map, filter, all, any, getattr, hasattr, setattr, callable, isinstance, issubclass, closures, and memoization decorators. It demonstrates how to use these functions and decorators through examples. Built-in functions like map, filter and decorators allow extending functionality of functions. Closures enable functions to remember values in enclosing scopes. The @decorator syntax is demonstrated to be equivalent to applying a function to another function.
The document discusses functions in C++. It begins by showing an example of copying and pasting code to compute 3^4 and 6^5, which is inefficient. It then demonstrates defining a function called raiseToPower() that takes a base and exponent as arguments and computes the power in a reusable way. The document explains the syntax of defining functions, including the return type, arguments, body, and return statement. It also covers topics like function overloading, function prototypes, recursion, and global versus local variables.
Java/Scala Lab: Анатолий Кметюк - Scala SubScript: Алгебра для реактивного пр...GeeksLab Odessa
SubScript - это расширение языка Scala, добавляющее поддержку конструкций и синтаксиса аглебры общающихся процессов (Algebra of Communicating Processes, ACP). SubScript является перспективным расширением, применимым как для разработки высоконагруженных параллельных систем, так и для простых персональных приложений.
FS2 (previously called Scalaz-Stream) is a library that facilitates purely functional API to encode stream processing in a modular and composable manner.
Due to its functional abstraction around "streams" of data, FS2 enables isolating and delaying the side-effects until the streams are fully composed and assembled into its final execution context.
The main objectives of this talk are to get started with FS2, particularly with its functional approach to stream processing, and to dive into details of its semantics.
JavaScript Advanced - Useful methods to power up your codeLaurence Svekis ✔
Get this Course
https://www.udemy.com/javascript-course-plus/?couponCode=SLIDESHARE
Useful methods and JavaScript code snippets power up your code and make even more happen with it.
This course is perfect for anyone who has fundamental JavaScript experience and wants to move to the next level. Use and apply more advanced code, and do more with JavaScript.
Everything you need to learn more about JavaScript
Source code is included
60+ page Downloadable PDF guide with resources and code snippets
3 Challenges to get you coding try the code
demonstrating useful JavaScript methods that can power up your code and make even more happen with it.
Course lessons will cover
JavaScript Number Methods
JavaScript String Methods
JavaScript Math - including math random
DOMContentLoaded - DOM ready when the document has loaded.
JavaScript Date - Date methods and how to get set and use date.
JavaScript parse and stringify - strings to objects back to strings
JavaScript LocalStorage - store variables in the user browser
JavaScript getBoundingClientRect() - get the dimensions of an element
JavaScript Timers setTimeout() setInterval() requestAnimationFrame() - Run code when you want too
encodeURIComponent - encoding made easy
Regex - so powerful use it to get values from your string
prototype - extend JavaScript objects with customized powers
Try and catch - perfect for error and testing
Fetch xHR requests - bring content in from servers
and more
No libraries, no shortcuts just learning JavaScript making it DYNAMIC and INTERACTIVE web application.
Step by step learning with all steps included.
What is an RPA CoE? Session 1 – CoE VisionDianaGray10
In the first session, we will review the organization's vision and how this has an impact on the COE Structure.
Topics covered:
• The role of a steering committee
• How do the organization’s priorities determine CoE Structure?
Speaker:
Chris Bolin, Senior Intelligent Automation Architect Anika Systems
Main news related to the CCS TSI 2023 (2023/1695)Jakub Marek
An English 🇬🇧 translation of a presentation to the speech I gave about the main changes brought by CCS TSI 2023 at the biggest Czech conference on Communications and signalling systems on Railways, which was held in Clarion Hotel Olomouc from 7th to 9th November 2023 (konferenceszt.cz). Attended by around 500 participants and 200 on-line followers.
The original Czech 🇨🇿 version of the presentation can be found here: https://www.slideshare.net/slideshow/hlavni-novinky-souvisejici-s-ccs-tsi-2023-2023-1695/269688092 .
The videorecording (in Czech) from the presentation is available here: https://youtu.be/WzjJWm4IyPk?si=SImb06tuXGb30BEH .
Discover top-tier mobile app development services, offering innovative solutions for iOS and Android. Enhance your business with custom, user-friendly mobile applications.
"Scaling RAG Applications to serve millions of users", Kevin GoedeckeFwdays
How we managed to grow and scale a RAG application from zero to thousands of users in 7 months. Lessons from technical challenges around managing high load for LLMs, RAGs and Vector databases.
For the full video of this presentation, please visit: https://www.edge-ai-vision.com/2024/06/temporal-event-neural-networks-a-more-efficient-alternative-to-the-transformer-a-presentation-from-brainchip/
Chris Jones, Director of Product Management at BrainChip , presents the “Temporal Event Neural Networks: A More Efficient Alternative to the Transformer” tutorial at the May 2024 Embedded Vision Summit.
The expansion of AI services necessitates enhanced computational capabilities on edge devices. Temporal Event Neural Networks (TENNs), developed by BrainChip, represent a novel and highly efficient state-space network. TENNs demonstrate exceptional proficiency in handling multi-dimensional streaming data, facilitating advancements in object detection, action recognition, speech enhancement and language model/sequence generation. Through the utilization of polynomial-based continuous convolutions, TENNs streamline models, expedite training processes and significantly diminish memory requirements, achieving notable reductions of up to 50x in parameters and 5,000x in energy consumption compared to prevailing methodologies like transformers.
Integration with BrainChip’s Akida neuromorphic hardware IP further enhances TENNs’ capabilities, enabling the realization of highly capable, portable and passively cooled edge devices. This presentation delves into the technical innovations underlying TENNs, presents real-world benchmarks, and elucidates how this cutting-edge approach is positioned to revolutionize edge AI across diverse applications.
This talk will cover ScyllaDB Architecture from the cluster-level view and zoom in on data distribution and internal node architecture. In the process, we will learn the secret sauce used to get ScyllaDB's high availability and superior performance. We will also touch on the upcoming changes to ScyllaDB architecture, moving to strongly consistent metadata and tablets.
AppSec PNW: Android and iOS Application Security with MobSFAjin Abraham
Mobile Security Framework - MobSF is a free and open source automated mobile application security testing environment designed to help security engineers, researchers, developers, and penetration testers to identify security vulnerabilities, malicious behaviours and privacy concerns in mobile applications using static and dynamic analysis. It supports all the popular mobile application binaries and source code formats built for Android and iOS devices. In addition to automated security assessment, it also offers an interactive testing environment to build and execute scenario based test/fuzz cases against the application.
This talk covers:
Using MobSF for static analysis of mobile applications.
Interactive dynamic security assessment of Android and iOS applications.
Solving Mobile app CTF challenges.
Reverse engineering and runtime analysis of Mobile malware.
How to shift left and integrate MobSF/mobsfscan SAST and DAST in your build pipeline.
Northern Engraving | Modern Metal Trim, Nameplates and Appliance PanelsNorthern Engraving
What began over 115 years ago as a supplier of precision gauges to the automotive industry has evolved into being an industry leader in the manufacture of product branding, automotive cockpit trim and decorative appliance trim. Value-added services include in-house Design, Engineering, Program Management, Test Lab and Tool Shops.
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsDianaGray10
Join us to learn how UiPath Apps can directly and easily interact with prebuilt connectors via Integration Service--including Salesforce, ServiceNow, Open GenAI, and more.
The best part is you can achieve this without building a custom workflow! Say goodbye to the hassle of using separate automations to call APIs. By seamlessly integrating within App Studio, you can now easily streamline your workflow, while gaining direct access to our Connector Catalog of popular applications.
We’ll discuss and demo the benefits of UiPath Apps and connectors including:
Creating a compelling user experience for any software, without the limitations of APIs.
Accelerating the app creation process, saving time and effort
Enjoying high-performance CRUD (create, read, update, delete) operations, for
seamless data management.
Speakers:
Russell Alfeche, Technology Leader, RPA at qBotic and UiPath MVP
Charlie Greenberg, host
Skybuffer SAM4U tool for SAP license adoptionTatiana Kojar
Manage and optimize your license adoption and consumption with SAM4U, an SAP free customer software asset management tool.
SAM4U, an SAP complimentary software asset management tool for customers, delivers a detailed and well-structured overview of license inventory and usage with a user-friendly interface. We offer a hosted, cost-effective, and performance-optimized SAM4U setup in the Skybuffer Cloud environment. You retain ownership of the system and data, while we manage the ABAP 7.58 infrastructure, ensuring fixed Total Cost of Ownership (TCO) and exceptional services through the SAP Fiori interface.
Fueling AI with Great Data with Airbyte WebinarZilliz
This talk will focus on how to collect data from a variety of sources, leveraging this data for RAG and other GenAI use cases, and finally charting your course to productionalization.
Conversational agents, or chatbots, are increasingly used to access all sorts of services using natural language. While open-domain chatbots - like ChatGPT - can converse on any topic, task-oriented chatbots - the focus of this paper - are designed for specific tasks, like booking a flight, obtaining customer support, or setting an appointment. Like any other software, task-oriented chatbots need to be properly tested, usually by defining and executing test scenarios (i.e., sequences of user-chatbot interactions). However, there is currently a lack of methods to quantify the completeness and strength of such test scenarios, which can lead to low-quality tests, and hence to buggy chatbots.
To fill this gap, we propose adapting mutation testing (MuT) for task-oriented chatbots. To this end, we introduce a set of mutation operators that emulate faults in chatbot designs, an architecture that enables MuT on chatbots built using heterogeneous technologies, and a practical realisation as an Eclipse plugin. Moreover, we evaluate the applicability, effectiveness and efficiency of our approach on open-source chatbots, with promising results.
Have you ever been confused by the myriad of choices offered by AWS for hosting a website or an API?
Lambda, Elastic Beanstalk, Lightsail, Amplify, S3 (and more!) can each host websites + APIs. But which one should we choose?
Which one is cheapest? Which one is fastest? Which one will scale to meet our needs?
Join me in this session as we dive into each AWS hosting service to determine which one is best for your scenario and explain why!
"Frontline Battles with DDoS: Best practices and Lessons Learned", Igor IvaniukFwdays
At this talk we will discuss DDoS protection tools and best practices, discuss network architectures and what AWS has to offer. Also, we will look into one of the largest DDoS attacks on Ukrainian infrastructure that happened in February 2022. We'll see, what techniques helped to keep the web resources available for Ukrainians and how AWS improved DDoS protection for all customers based on Ukraine experience
Monitoring and Managing Anomaly Detection on OpenShift.pdfTosin Akinosho
Monitoring and Managing Anomaly Detection on OpenShift
Overview
Dive into the world of anomaly detection on edge devices with our comprehensive hands-on tutorial. This SlideShare presentation will guide you through the entire process, from data collection and model training to edge deployment and real-time monitoring. Perfect for those looking to implement robust anomaly detection systems on resource-constrained IoT/edge devices.
Key Topics Covered
1. Introduction to Anomaly Detection
- Understand the fundamentals of anomaly detection and its importance in identifying unusual behavior or failures in systems.
2. Understanding Edge (IoT)
- Learn about edge computing and IoT, and how they enable real-time data processing and decision-making at the source.
3. What is ArgoCD?
- Discover ArgoCD, a declarative, GitOps continuous delivery tool for Kubernetes, and its role in deploying applications on edge devices.
4. Deployment Using ArgoCD for Edge Devices
- Step-by-step guide on deploying anomaly detection models on edge devices using ArgoCD.
5. Introduction to Apache Kafka and S3
- Explore Apache Kafka for real-time data streaming and Amazon S3 for scalable storage solutions.
6. Viewing Kafka Messages in the Data Lake
- Learn how to view and analyze Kafka messages stored in a data lake for better insights.
7. What is Prometheus?
- Get to know Prometheus, an open-source monitoring and alerting toolkit, and its application in monitoring edge devices.
8. Monitoring Application Metrics with Prometheus
- Detailed instructions on setting up Prometheus to monitor the performance and health of your anomaly detection system.
9. What is Camel K?
- Introduction to Camel K, a lightweight integration framework built on Apache Camel, designed for Kubernetes.
10. Configuring Camel K Integrations for Data Pipelines
- Learn how to configure Camel K for seamless data pipeline integrations in your anomaly detection workflow.
11. What is a Jupyter Notebook?
- Overview of Jupyter Notebooks, an open-source web application for creating and sharing documents with live code, equations, visualizations, and narrative text.
12. Jupyter Notebooks with Code Examples
- Hands-on examples and code snippets in Jupyter Notebooks to help you implement and test anomaly detection models.
Session 1 - Intro to Robotic Process Automation.pdfUiPathCommunity
👉 Check out our full 'Africa Series - Automation Student Developers (EN)' page to register for the full program:
https://bit.ly/Automation_Student_Kickstart
In this session, we shall introduce you to the world of automation, the UiPath Platform, and guide you on how to install and setup UiPath Studio on your Windows PC.
📕 Detailed agenda:
What is RPA? Benefits of RPA?
RPA Applications
The UiPath End-to-End Automation Platform
UiPath Studio CE Installation and Setup
💻 Extra training through UiPath Academy:
Introduction to Automation
UiPath Business Automation Platform
Explore automation development with UiPath Studio
👉 Register here for our upcoming Session 2 on June 20: Introduction to UiPath Studio Fundamentals: https://community.uipath.com/events/details/uipath-lagos-presents-session-2-introduction-to-uipath-studio-fundamentals/
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...Jason Yip
The typical problem in product engineering is not bad strategy, so much as “no strategy”. This leads to confusion, lack of motivation, and incoherent action. The next time you look for a strategy and find an empty space, instead of waiting for it to be filled, I will show you how to fill it in yourself. If you’re wrong, it forces a correction. If you’re right, it helps create focus. I’ll share how I’ve approached this in the past, both what works and lessons for what didn’t work so well.
High performance Serverless Java on AWS- GoTo Amsterdam 2024Vadym Kazulkin
Java is for many years one of the most popular programming languages, but it used to have hard times in the Serverless community. Java is known for its high cold start times and high memory footprint, comparing to other programming languages like Node.js and Python. In this talk I'll look at the general best practices and techniques we can use to decrease memory consumption, cold start times for Java Serverless development on AWS including GraalVM (Native Image) and AWS own offering SnapStart based on Firecracker microVM snapshot and restore and CRaC (Coordinated Restore at Checkpoint) runtime hooks. I'll also provide a lot of benchmarking on Lambda functions trying out various deployment package sizes, Lambda memory settings, Java compilation options and HTTP (a)synchronous clients and measure their impact on cold and warm start times.
12. Concurrent Tasks
Task.await timeout
await(task, timeout 5000)
…
A timeout, in milliseconds, can be given with default value
of 5000. If the timeout is exceeded, then the current
process will exit.
…
iex(22)> Task.async(fn -> Process.sleep(6_000) end) |> Task.await()
** (exit) exited in: Task.await(%Task{owner: #PID<0.88.0>, pid:
#PID<0.156.0>, ref: #Reference<0.891801449.431751175.151026>}, 5000)
** (EXIT) time out
(elixir) lib/task.ex:501: Task.await/2
13. Storing state
defmodule Storage do
def recursive(state) do
receive do
{:add, caller_pid, value} ->
new_state = state + value
send(caller_pid, {:result, new_state})
recursive(new_state)
end
end
end
iex(2)> storage_pid = spawn(fn -> Storage.recursive(0) end)
iex(3)> send(storage_pid, {:add, self(), 2})
iex(4)> send(storage_pid, {:add, self(), 2})
iex(5)> send(storage_pid, {:add, self(), 2})
iex(6)> flush()
{:result, 2}
{:result, 4}
{:result, 6}
14. Storing state
Agent
iex(7)> {:ok, pid} = Agent.start_link(fn -> 0 end)
{:ok, #PID<0.101.0>}
iex(8)> Agent.update(pid, fn state -> state + 1 end)
:ok
iex(9)> Agent.get(pid, fn state -> state end)
1
update(agent, fun, timeout 5000)
get(agent, module, fun, args, timeout 5000)
16. GenServer
A behaviour module for implementing the server of a client-
server relation.
A GenServer is a process like any other Elixir process and it
can be used to keep state, execute code asynchronously
and so on.
17. GenServer
defmodule Stack do
use GenServer
# Client
def start_link(default) do
GenServer.start_link(__MODULE__, default)
end
def push(pid, item) do
GenServer.cast(pid, {:push, item})
end
def pop(pid) do
GenServer.call(pid, :pop)
end
# Server (callbacks)
def handle_call(:pop, _from, [h | t]) do
{:reply, h, t}
end
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
end
18. GenServer
defmodule Stack do
use GenServer
# Client
def start_link(default) do
GenServer.start_link(__MODULE__, default)
end
def push(pid, item) do
GenServer.cast(pid, {:push, item})
end
def pop(pid) do
GenServer.call(pid, :pop)
end
# Server (callbacks)
def handle_call(:pop, _from, [h | t]) do
{:reply, h, t}
end
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
end
Executed in caller process
19. GenServer
defmodule Stack do
use GenServer
# Client
def start_link(default) do
GenServer.start_link(__MODULE__, default)
end
def push(pid, item) do
GenServer.cast(pid, {:push, item})
end
def pop(pid) do
GenServer.call(pid, :pop)
end
# Server (callbacks)
def handle_call(:pop, _from, [h | t]) do
{:reply, h, t}
end
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
end
Executed in server process
20. GenServer: timeout
call(server, request, timeout 5000)
def push(pid, item) do
GenServer.cast(pid, {:push, item})
end
def pop(pid) do
GenServer.call(pid, :pop)
end
# Server (callbacks)
@impl true
def handle_call(:pop, _from, [h | t]) do
Process.sleep(30_000)
{:reply, h, t}
end
@impl true
def handle_cast({:push, item}, state) do
{:noreply, [item | state]}
end
Executed in caller process
Executed in server process
21. GenServer: timeout
iex(2)> {:ok, pid} = Stack.start_link([])
{:ok, #PID<0.95.0>}
iex(3)> Enum.each(1..5, &Stack.push(pid, &1))
:ok
ex(4)> Stack.pop(pid)
** (exit) exited in: GenServer.call(#PID<0.95.0>, :pop, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:836: GenServer.call/3
iex(4)> Stack.pop(pid)
** (exit) exited in: GenServer.call(#PID<0.95.0>, :pop, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:836: GenServer.call/3
iex(4)> Stack.pop(pid)
** (exit) exited in: GenServer.call(#PID<0.95.0>, :pop, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:836: GenServer.call/3
iex(4)> Stack.pop(pid)
** (exit) exited in: GenServer.call(#PID<0.95.0>, :pop, 5000)
** (EXIT) time out
(elixir) lib/gen_server.ex:836: GenServer.call/3
iex(4)> Process.info(pid, :messages)
{:messages,
[
{:"$gen_call", {#PID<0.88.0>, #Reference<0.3022523149.3093823489.83754>},
:pop},
{:"$gen_call", {#PID<0.88.0>, #Reference<0.3022523149.3093823489.83774>},
:pop},
{:"$gen_call", {#PID<0.88.0>, #Reference<0.3022523149.3093823489.83794>},
:pop}
]}
Executed in caller process
Executed in server process
24. Digital Signature Microservice
• Microservice - part of the Ukrainian eHealth system
infrastructure
• Digital signature validation
• Ukrainian standard DSTU 4145-2002
• Integration with proprietary C library via NIF
25. Digital Signature Microservice
Digital Signature
Microservice
NIF
Proprietary
DSTU
4145-2002
LIB
Digitally signed
content
< 5s
Decoded content
Signer info
Signature validation
Certificates
OSCP Server
27. Sounds easy?
Digital Signature Microservice
DigitalSignatureLib.processPKCS7Data(…)
DigitalSignatureLib.processPKCS7Data(…)
DigitalSignatureLib.processPKCS7Data(…)
DigitalSignatureLib.processPKCS7Data(…)
Elixir Process
Elixir Process
Elixir Process
Elixir Process
Incoming Requests
200 OK
200 OK
200 OK
200 OK
Responses
35. Problem 2 solution: architecture
DS
DS
DS
DS DS
DS
DS
DS
Load
Balancer
Reduce pressure on individual MS
36. Problem 2 solution: catch Exit
def process_signed_content(signed_content, check) do
gen_server_timeout =
Confex.fetch_env(:digital_signature_api,
:nif_service_timeout)
try do
GenServer.call(__MODULE__, {:process_signed_content,
signed_content, check}, gen_server_timeout)
catch
:exit, {:timeout, error} ->
{:error, {:nif_service_timeout, error}}
end
end
424 Failed Dependency
37. Problem 3: message queue
NifService (GenServer)
Processed requests
2s
2s
2s
2s
Message queue
Sequential
responses
200 OK
2s
200 OK
4s
424
5s
424
5s
2s
2s
Expired requests
New requests
38. Problem 3 solution: pass
message expiration time
...
# Callbacks
def handle_call({:process_signed_content, signed_content, check, message_exp_time}, _from, certs_cache_ttl, certs})
do
processing_result =
if NaiveDateTime.diff(message_exp_time, NaiveDateTime.utc_now(), :millisecond) > 250 do
check = unless is_boolean(check), do: true
do_process_signed_content(signed_content, certs, check, SignedData.new())
else
{:error, {:nif_service_timeout, "messaqe queue timeout"}}
end
{:reply, processing_result, {certs_cache_ttl, certs}}
End
...
# Client
def process_signed_content(signed_content, check) do
gen_server_timeout = Confex.fetch_env!(:digital_signature_api, :nif_service_timeout)
message_exp_time = NaiveDateTime.add(NaiveDateTime.utc_now(), gen_server_timeout, :millisecond)
try do
GenServer.call(__MODULE__, {:process_signed_content, signed_content, check, message_exp_time}, gen_server_timeout)
catch
:exit, {:timeout, error} ->
{:error, {:nif_service_timeout, error}}
end
end
...
39. Problem 3 solution: pass
message expiration time
NifService (GenServer)
…
Expired
Expired
Within threshold
Message queue
…
40. Problem 3 advanced solution:
QueueService
NifService
DigitalSignatureLib.
processPKCS7Data(…)
QueueService
:queue
Monitoring & Control
41.
42. Memory management
Binary terms which are larger than 64 bytes are not stored in a process private
heap.
They are called Refc Binary (Reference Counted Binary) and are stored in a
large Shared Heap which is accessible by all processes who have the pointer
of that Refc Binaries.
That pointer is called ProcBin and is stored in a process private heap.
The GC for the shared heap is reference counting.
Collecting those Refc messages depends on collecting of all ProcBin objects
even ones that are inside the middleware process.
Unfortunately because ProcBins are just a pointer hence they are so cheap
and it could take so long to happen a GC inside the middleware process.
44. Garbage Collect
...
# Callbacks
def init(certs_cache_ttl) do
certs = CertAPI.get_certs_map()
Process.send_after(self(), :refresh, certs_cache_ttl)
{:ok, {certs_cache_ttl, certs}}
end
...
def handle_info(:refresh, {certs_cache_ttl, _certs}) do
certs = CertAPI.get_certs_map()
# GC
:erlang.garbage_collect(self())
Process.send_after(self(), :refresh, certs_cache_ttl)
{:noreply, {certs_cache_ttl, certs}}
end
...
45. Garbage Collect
handle_call(request, from, state)
{:reply, reply, new_state, timeout() | :hibernate}
Hibernating a GenServer causes garbage collection and leaves
a continuous heap that minimises the memory used by the
process
Returning {:reply, reply, new_state, timeout} is similar to
{:reply, reply, new_state} except handle_info(:timeout,
new_state) will be called after timeout milliseconds if no
messages are received
46. Useful links
Saša Jurić "Elixir in Action, Second Edition”
https://www.manning.com/books/elixir-in-action-second-edition
Andrea Leopardi - Concurrent and Resilient Connections to Outside the
BEAM (ElixirConfEU 2016)
https://www.youtube.com/watch?time_continue=1884&v=U1Ry7STEFiY
GenServer call time-outs
https://cultivatehq.com/posts/genserver-call-timeouts/
Elixir Memory - Not Quite Free
https://stephenbussey.com/2018/05/09/elixir-memory-not-quite-free.html
Erlang Garbage Collection Details and Why It Matters
https://hamidreza-s.github.io/erlang%20garbage%20collection%20memory%20layout%20soft%20realtime/
2015/08/24/erlang-garbage-collection-details-and-why-it-matters.html