Some patches, provided by ALFred, did introduce some new platforms under Linux: Linux x86 (aka Intel 32-bit) Linux x64 (aka Intel 64-bit) Linux AARCH32 (aka ARM 32-bit) Linux AARCH64 (aka ARM 64-bit) It needs the latest trunk version of the FPC compiler, and the "Interface Enhanced RTTI" […]
Open Source › mORMot Framework
2016-05-30
SOA and stub/mock working on Linux x86, x64, arm32 and aarch64
2016-05-30. Open Source › mORMot Framework
2016-05-14
Anti-forensic, safe storage of private keys
2016-05-14. Open Source › mORMot Framework

In any modern application, especially on
Client/Server nTier architecture as our little mORMot offers, we
often have to persist some private keys in a safe way.
Problem with such keys is that they consist in small amount of bytes (typically
16 or 32 bytes), easy to be left somewhere in disk or memory.
Given the abilities of recent forensic data recovery
methods, data can't be destroyed on magnetic or flash storage media
reliably.
We have just added to our SynCrypto OpenSource library
the Anti-forensic Information Splitter algorithm, as proposed in
TKS1, and implemented in the LUKS
standard.
LUKS is the de-facto standard of platform-independent standard on-disk
format for use in various tools.
2016-04-09
AES-256 based Cryptographically Secure Pseudo-Random Number Generator (CSPRNG)
2016-04-09. Open Source › mORMot Framework
Everyone knows about the pascal random()
function.
It returns some numbers, using a linear
congruential generator, with a multiplier of 134775813,
in its Delphi implementation.
It is fast, but not really secure. Output is very predictable, especially if
you forgot to execute the RandSeed()
procedure.
In real world scenarios, safety always requires random numbers, e.g. for
key/nonce/IV/salt/challenge generation.
The less predictable, the better.
We just included a Cryptographically
Secure Pseudo-Random Number Generator (CSPRNG) into our
SynCrypto.pas unit.
The TAESPRNG
class would use real system entropy to generate
a sequence of pseudorandom bytes, using AES-256, so returning highly
unpredictable content.
2016-01-09
Safe locks for multi-thread applications
2016-01-09. Open Source › mORMot Framework
Once your application is multi-threaded, concurrent data access should be
protected. We already wrote about how debugging multi-thread
applications may be hard.
Otherwise, a "race
condition" issue may appear: for instance, if two threads modify a variable
at the same time (e.g. decrease a counter), values may become incoherent and
unsafe to use. Another symptom of broken logic is the "deadlock", by which the whole
application appears to be blocked and unresponsive, when two threads have a
wrong use of the lock, so are blocking each-others.
On a server system, which is expected to run 24/7 with no maintenance, such
issues are to be avoided.
In Delphi, protection of a resource (which may be an object, or any
variable) is usually done via Critical
Sections.
A critical section is an object used to make sure, that some part of
the code is executed only by one thread at a time. A critical section
needs to be created/initialized before it can be used and be released when it
is not needed anymore. Then, some code is protected using Enter/Leave
methods, which would lock its execution: in practice, only a single
thread would own the critical section, so only a single thread would
be able to execute this code section, and other threads would wait until the
lock is released. For best performance, the protected sections should be as
small as possible - otherwise the benefit of using threads may be voided, since
any other thread would wait for the thread owning the critical section
to release the lock.
We will now see that Delphi's TCriticalSection
may have
potential issues, and what our framework proposes to ease critical
section use in your applications.
2015-12-11
Audit Trail for Services
2015-12-11. Open Source › mORMot Framework
We have seen previously how the ORM part of the framework is able to provide
an Audit
Trail for change tracking.
It is a very convenient way of storing the change of state of the data.
On the other side, in any modern SOA solution, data is not at the center any
more, but services.
Sometimes, the data is not stored within your server, but in a third-party
Service-Oriented Architecture (SOA).
Being able to monitor the service execution of the whole system becomes sooner
or later mandatory.
Our framework allows to create an Audit Trail of any incoming or outgoing service operation, in a secure, efficient and automated way.
2015-11-17
Benefits of interface callbacks instead of class messages
2015-11-17. Open Source › mORMot Framework
If you compare with existing client/server SOA solutions (in Delphi, Java,
C# or even in Go or other frameworks), mORMot's
interface
-based
callback mechanism sounds pretty unique and easy to work with.
Most Events Oriented solutions do use a set of dedicated
messages to propagate the events, with a centralized Message
Bus (like MSMQ or
JMS), or a
P2P/decentralized approach (see e.g. ZeroMQ or NanoMsg). In practice, you are expected to
define one class
per message, the class
fields being
the message values. You would define e.g. one class
to notify a
successful process, and another class
to notify an error. SOA
services would eventually tend to be defined by a huge number of individual
classes, with the temptation of re-using existing classes in several
contexts.
Our interface
-based approach allows to gather all events:
- In a single
interface
type per notification, i.e. probably per service operation; - With one method per event;
- Using method parameters defining the event values.
Since asynchronous notifications are needed most of the time, method
parameters would be one-way, i.e. defined only
as const
- in such case, an evolved algorithm would
transparently gather those outgoing messages, to enhance scalability when
processing such asynchronous events. Blocking request may also be defined
as var/out
, as we will see below, inWorkflow
adaptation.
Behind the scene, the framework would still transmit raw messages over IP
sockets (currently over a
WebSockets connection), like other systems, but events notification would
benefit from using interfaces, on both server and client sides.
We will now see how...
2015-09-28
mORMot show case: Illustrated Spare Parts Catalog
2015-09-28. Open Source › mORMot Framework
Illustrated Spare Parts Catalog is, as its name suggests, a software for creating and publishing spare parts catalogs. It uses mORMot for client-server communication and ORM, and SynPdf for the reporting. Sounds like a powerful solution. It is also a testimony that you could use big databases (20 GB […]
2015-09-25
ORM TNullable* fields for NULL storage
2015-09-25. Open Source › mORMot Framework
In Delphi code, NULLable types do not exist as such. There is no
native int?
type, as in C#.
But at SQL and JSON levels, the NULL value does exist and should be converted
as expected by the ORM.
In SQLite3 itself, NULL is handled as stated in http://www.sqlite.org/lang_expr.html
(see e.g. IS
and IS NOT
operators).
It is worth noting that NULL handling is not consistent among all existing
database engines, e.g. when you are comparing NULL with non NULL values... so
we recommend using it with care in any database statements, or only with proper
(unit) testing, when you switch from one database engine to another.
By default, in the mORMot ORM/SQL code, NULL will appear only in
case of a BLOB storage with a size of 0
bytes.
Otherwise, you should not see it as a value,
in most kinds of ORM properties.
Null-oriented value types have been implemented in our framework, since the object pascal language does not allow defining a nullable type (yet).
We choose to store those values as variant
, with a set of
TNullable
dedicated types, as defined in
mORMot.pas
:
type TNullableInteger = type variant; TNullableBoolean = type variant; TNullableFloat = type variant; TNullableCurrency = type variant; TNullableDateTime = type variant; TNullableTimeLog = type variant; TNullableUTF8Text = type variant;
2015-08-23
"SQL and NoSQL", not "SQL vs NoSQL"
2015-08-23. Open Source › mORMot Framework
You know certainly that our mORMot Open Source framework is an ORM,
i.e. mapping objects to a relational / SQL database (Object
Relational Mapping).
You may have followed also that it is able to connect to a
NoSQL database, like MongoDB, and
that the objects are then mapped via an ODM (Object
Document Mapping) - the original SQL SELECT are even
translated on the fly to MongoDB queries.
But thanks to mORMot, it is not "SQL vs NoSQL" - but
"SQL and NoSQL".
You are not required to make an exclusive choice.
You can share best of both worlds, depending on your application needs.
In fact, the framework is able to add NoSQL features to a regular relational / SQL database, by storing JSON documents in TEXT columns.
In your end-user code, you just define a variant
field in
the ORM, and store a
TDocVariant document within.
We also added some dedicated functions at SQL level, so that
SQLite3 could be used as embedded fast engine, and provide
advanced WHERE clauses on this JSON content.
2015-08-15
Breaking Change in mORMot WebSockets binary protocol
2015-08-15. Open Source › mORMot Framework
Among all its means of transmission, our mORMot framework
features
WebSockets, allowing bidirectional communications, and interface-based
callbacks for real time notification of SOA events.
After several months of use in production, we identified some needed changes
for this just emerged feature.
We committed
today a breaking change of the data layout used for our proprietary
WebSockets binary protocol.
From our tests, it would increase the performance and decrease the resource
consumption, especially in case of high number of messages.
2015-07-14
New blog about mORMot
2015-07-14. Open Source › mORMot Framework
An enthusiastic mORMot user, named willo in the forum, just started a blog about his experiments with our framework.
The information there is clear, simple, and right to the point.
If you are a little lost in our huge documentation, it is a good place to
start!
2015-06-30
Faster String process using SSE 4.2 Text Processing Instructions STTNI
2015-06-30. Open Source › mORMot Framework
A lot of our code, and probably yours, is highly relying on text process. In our mORMot framework, most of its features use JSON text, encoded as UTF-8. Profiling shows that a lot of time is spent computing the end of a text buffer, or comparing text content. You may know that In its SSE4.2 feature […]
2015-06-16
Handling Cross-Platform Time Zones
2015-06-16. Open Source › mORMot Framework
One common problem when handling dates and times, is that time is shown and entered as local, whereas the computer should better use non-geographic information - especially on a Client-Server architecture, where both ends may not be on the same physical region.
A time zone is a region that observes a uniform standard time for
legal, commercial, and social purposes.
Time zones tend to follow the boundaries of countries and their subdivisions
because it is convenient for areas in close commercial or other communication
to keep the same time.
Most of the time zones on land are offset from Coordinated Universal
Time (UTC) by a whole number of hours, or minutes.
Even worse, some countries use daylight saving time for part of the year,
typically by changing clocks by an hour, twice every year.
The main rule is that any date and time stored should be stored in
UTC, or with an explicit Zone identifier (i.e. an explicit offset to
the UTC value).
Our framework expects this behavior: every date/time value stored and handled
by the ORM, SOA, or any other part of it, is expected to be UTC-encoded.
At presentation layer (e.g. the User Interface), conversion to/from local times
should take place, so that the end-user is provided with friendly clock-wall
compatible timing.
As you may guess, handling time zones is a complex task, which should be
managed by the Operating System itself.
Since this cultural material is constantly involving, it is updated as part of
the OS.
In practice, current local time could be converted from UTC from the current system-wide time zone. One of the only parameters you have to set when installing an Operating System is to pickup the keyboard layout... and the current time zone to be used. But in a client-server environment, you may have to manage several time zones on the server side: so you can't rely on this global setting.
One sad - but predictable - news is that there is no common way of encoding
time zone information.
Under Windows, the registry contains a list of time zones, and the
associated time bias data. Most POSIX systems (including Linux and Mac
OSX) do rely on the IANA database, also called tzdata
- you may
have noticed that this particular package is often updated with your
system.
Both zone identifiers do not map, so our framework needed something to be
shared on all systems.
2015-06-01
Updated Slides about ORM SOA MVC SOLID DDD
2015-06-01. Open Source › mORMot Framework
One year ago, we published a set of slides about the main concepts implemented by our framework. Mainly about ORM (and ODM), NoSQL, JSON, SOA, MVC (and MVVM), SOLID, DDD, CQRS and some patterns like Stubs, Mocks, Factory, Repository, Unit-Of-Work. Worth a look, if you want to find out the benefits […]
2015-05-18
CQRS Persistence Service of any DDD object with mORMot
2015-05-18. Open Source › mORMot Framework
We introduced DDD concepts some time ago, in a series of articles in this blog. At that time, we proposed a simple way of using mORMot types to implement DDD in your applications. But all Domain Entitities being tied to the framework TSQLRecord class did appear as a limitation, breaking the […]
2015-05-14
Using TSynLog with a lot of threads? PYou should better upgrade your source
2015-05-14. Open Source › mORMot Framework
We identified and fixed today several issues which may affect applications creating a lot of threads (i.e. not using a thread pool). The symptom was an unexpected access violation, when you reach a multiple of 256 threads count. You should better upgrade to at least revision 1.18.1351 if your […]
2015-04-12
Why Transmitting Exceptions in SOA services is not a good idea
2015-04-12. Open Source › mORMot Framework
Usually, in Delphi application (like in most high-level languages), errors
are handled via exceptions. By default, any Exception
raised on the server side, within an interface
-based service
method, will be intercepted, and transmitted as an error to the client side,
then a safe but somewhat obfuscated EInterfaceFactoryException
will be raised on the client side, containing additional information serialized
as JSON.
You may wonder why exceptions are not transmitted and raised directly on the client side, with our mORMot framework interface-based services, as if they were executed locally.
We will now detail some arguments, and patterns to be followed.
2015-04-06
Asynchronous Service - WebSockets, Callbacks and Publish-Subscribe
2015-04-06. Open Source › mORMot Framework

When publishing SOA services, most of them are defined as
stateless, in a typical query/answer pattern - see
Service-Oriented Architecture (SOA).
This fits exactly with the RESTful approach of Client-Server
services via interfaces, as proposed by the framework.
But it may happen that a client application (or service) needs to know the state of a given service. In a pure stateless implementation, it will have to query the server for any state change, i.e. for any pending notification - this is called polling.
Polling may take place for instance:
- When a time consuming work is to be processed on the server side. In this case, the client could not wait for it to be finished, without raising a timeout on the HTTP connection: as a workaround, the client may start the work, then ask for its progress status regularly using a timer and a dedicated method call;
- When an unpredictable event is to be notified from the server side. In this case, the client should ask regularly (using a timer, e.g. every second), for any pending event, then react on purpose.
It may therefore sounds preferred, and in some case necessary, to have the ability to let the server notify one or several clients without any prior query, nor having the requirement of a client-side timer:
- Polling may be pretty resource consuming on both client and server sides, and add some unwanted latency;
- If immediate notification is needed, some kind of "long polling" algorithm may take place, i.e. the server will wait for a long time before returning the notification state if no event did happen: in this case, a dedicated connection is required, in addition to the REST one;
- In an event-driven systems, a lot of messages are sent to the clients: a proper publish/subscribe mechanism is preferred, otherwise the complexity of polling methods may increase and become inefficient and unmaintainable;
- Explicit push notifications may be necessary, e.g. when a lot of potential events, associated with a complex set of parameters, are likely to be sent by the client.
Our mORMot framework is therefore able to easily implement
asynchronous callbacks over WebSockets,
defining the callbacks as interface
parameters in service method
definitions - see
Available types for methods parameters.
Real-Time ORM Master/Slave Replication via WebSockets
2015-04-06. Open Source › mORMot Framework
In a previous
article, we presented how Master/Slave replication may be easily
implemented in mORMot's RESTful ORM.
Do not forget to
visit the corresponding paragraphs of our online documentation, which has
been updated, and is more accurate!
Sometimes, the on-demand synchronization is not enough.
So we have just introduced real-time replication via WebSockets.
For instance, you may need to:
- Synchronize a short list of always evolving items which should be reflected as soon as possible;
- Involve some kind of ACID-like behavior (e.g. handle money!) in your replicated data;
- Replicate not from a GUI application, but from a service, so use of a
TTimer
is not an option; - Combine REST requests (for ORM or services) and master/slave ORM replication on the same wire, e.g. in a multi-threaded application.
In this case, the framework is able to use WebSockets and
asynchronous callbacks to let the master/slave replication - see
Asynchronous callbacks - take place without the need to ask explicitly
for pending data.
You would need to use
TSQLRestServer.RecordVersionSynchronizeMasterStart
,
TSQLRestServer.RecordVersionSynchronizeSlaveStart
and
TSQLRestServer.RecordVersionSynchronizeSlaveStop
methods over the
proper kind of bidirectional connection.
2015-03-31
ORM Master/Slave Replication
2015-03-31. Open Source › mORMot Framework

As stated during
TSQLRecord fields definition, the ORM is able to maintain a revision
number for any TSQLRecord
table, so that it the table may be
easily synchronized remotely by another TSQLRestServer
instance.
If you define a TRecordVersion
published property, the ORM core
will fill this field just before any write with a monotonically increasing
revision number, and will take care of any deletion, so that those
modifications may be replayed later on any other database.
This synchronization will work as a strict master/slave replication
scheme, as a one-way on demand refresh of a replicated table.
Each write operation on the master database on a given table may be easily
reflected on one or several slave databases, with almost no speed nor storage
size penalty.
« previous entries - page 4 of 13 - next entries »