You are not logged in.
Monolithic is good if you want new people to join. Downloading a single zip file containing the entire project is still the lowest entry possible for newcomers and splitting it into seperate projects/modules will not lower the entry bar at all.
Have you checked using delphi own's rtti mechanisms , aka TRttiContext ?
zero is invalid, a valid ID value is >=1.
Hi ab, I have a situation where I only want to return http status code, currently the http rest server always sets Content-Type header to json unless overriden but there doesn't seem to be an easy way to control this via context in method based services.
It would be nice if there was a boolean property in TRestServerUriContext that would control that or even better if there were another overloaded Returns method that only specifies the status code.
best regards
Hi ab,
please check Pull request on github.
best regards.
Because it only happens at specific record count it's probably a JSON buffer issue. This is more true because if you add/delete properties from your TOrm class then the problematic record count changes.
Under certain conditions the internal encoding of a TRestBatch.add action changes.
Problem can be traced to mormot.orm.sqlite3, specifically to procedure TRestOrmServerDB.InternalBatchStop, specifically lines 2615-2628.
When the encoding is in BATCH_DIRECT_ADD it makes a call to EncodeMultiInsertSQLite3 with the SimpleFields parameter. Because TRecordVersion is not a "SimpleField" it's not accounted for and as such a discrepancy occurs between number of bits in SimpleFields (n) and actual fieldCount (n + 1) getting passed to this procedure.
Anyway, that's all from me, don't have the time right now but I hope this helps a bit.
Do you mean that I should use a TrestClientDB.Create(aRunningServer: TRestServerDB) ?
No, you should use an instance of TRestServerDB directly on server side.
I already have enabled PUREMORMOT2, I create a TRestServerDB instance before the http server and I can still have access to TRestServerDB.orm.add
Yes, that is the correct way.
example:
FDatabase.Orm.Add where FDatabase is an object instance of TRestServerDB class.
is it better to use TRestServerDB's orm interface directly ?
that's how you're supposed to use it. The only reason you can still call Add/Update/Delete directly from the TRestServerDB instance is because it's there for backwards compatibility with mORMot 1. If you define PUREMORMOT2 flag for your project then you will see those direct methods no longer available.
I believe that a REST interface procedure in a server called by a client will not have problems to access a main-central TRestServerDB instance to do database work
By default there is a lock at orm level so all threads orm access will be properly synchronized, shouldn't have a problem.
Isn't this just based on what the chosen database uses for the primary indexed column name in every table? For example, if you're using sqlite then yes you need to use RowID because that's the name of the indexed column, and you only have to do that anyway (AFAIK) if you bypass the ORM layer.
I'm in same boat as sakura, basically I've switched to mORMot 2 during development but aren't using it in production yet because the project isn't there yet.
Looking forward to testing it out, cheers.
Interesting, I personally use "DB Browser for Sqlite" also known as sqlitebrowser, open source tool https://github.com/sqlitebrowser/sqlitebrowser
You can with nginx, I don't use IIS. I don't know why you would want to remove method name, with mORMot you can dynamically link a method to any string using TRestServer.ServiceMethodRegister(...).
tbh the no root is better to be handled by whatever front-end reverse/balancing proxy you are using. It's trivial to do this in nginx.
Just a wild guess,
I assume your browser test is using a GET request, you should make a POST request instead. From the browsers perspective you're trying to access a cacheable resource, there's no reason to send a second request for the same resource if the first one is still waiting for server response. Either POST request or append a different parameter(Y) to the GET request for each X /root/example/delay?X=Y.
How would I then find and execute the correct function on that interface with the correct parameters? I assume I'll have to search for the methodindex from the interfacefactory and then step through and assign the declared parameters?
Have someone done something like this before?Since ExecuteCommand is private, how would the function be called after the parameters are assigned?
AFAIK it's already documented on how to call interface based services on server side : https://synopse.info/files/html/Synopse … #TITLE_421
can you try without variant late binding?
var v : variant;
begin
TDocVariant.New(v);
with TDocVariantData(v) do
begin
U['Code'] := '000';
U['Descr'] := 'xxx';
Names[0] := '222';
end;
end;
The issue you have is that you're executing database requests in the same thread as the user UI which is just bad all around. You should decouple your logic from the UI. Database requests should be done in a separate thread. However, this requires some threading knowledge on your own part. Please read : https://synopse.info/files/html/Synopse … #TITLE_304
let me rephrase , why exactly do you care if a batch transaction takes 50 ms? Does your client application lock up and stop responding?
Correct me if I'm wrong, but it seems from your comments that your primary concern is the user UI stalling/locking/delaying due to waiting for database action to complete?
I wasn't referring to the screenshot per se
since I've done minor changes in SynCommons.pas, it somehow failed to update/merge that file.
I would 100% expect tortoise to not auto overwrite your modifications if the two conflicted. Maybe you encountered a bug like you said but this just sounds normal operation to me. I've done the same thing in the past, I introduced manual changes in SynCommons for debugging or some other reason and tortoise would always soft-fail the repo update and I either had to dismiss my changes or manually merge the file in question.
Then again this is software , maybe you were/are using a tortoise version where such a bug exists. OR perhaps it has something to do with using a Subversion tool to update from a git repo, that may very well be the case.
Nice that you found out why but it really isn't the tools fault, there was clearly a conflict with your manual changes. The tool did it's job and prevented the loss of your modifications, it warned you that there is a conflict but you probably just closed the window. What you had to do is to click on the conflicted file in the update window and click manual resolve.... Then you would get an editor where you could manually merge or update the conflicted lines. The same thing would happen if you used any other tool/client.
I also like the Tortoise client, the only thing I change is that I use Beyond Compare as the editor of choice for merges&conflicts, highly recommend.
I found it way easier to just write little pascal programs in fpc then trying to understand some bash, awk, seed or regex crap ...
You can execute external programs with little effort using TProcess, https://wiki.freepascal.org/Executing_E … s#TProcess.
I haven't had any problems so far using this method.
Oh, didn't know you are using postgre, I have no experience with that database, maybe someone else will chime in, gl.
manually call TransactionBegin,Commit,Rollback, etc... and for vanilla sqlite the transaction will apply to the entire database.
Sounds like he needs a pivot table instead.
Where to report the problem?
fpc-devel mailing list is very active and probably will get noticed sooner then creating a git issue.
https://www.freepascal.org/maillist.html
I have managed to force fpcupdeluxe to install Free Pascal Compiler version 3.2.0-r45643 [2022/04/01] for i386
Not sure where you got that date from but 3.2.0 was released in 2020. Honestly if you're having issues just download 3.2.0 from offical freepascal webpage.
maybe his lib paths are wrong and is compiling/linking older version. Check your paths and do a full clean+build.
mORMot links external object files that haven't been compiled with -fPIC, you can avoid the errors by using external libraries instead,
for the errors you provided you need to set the following compile time flags :
NOSQLITE3STATIC
NOLIBDEFLATESTATIC
You can do this on command line or if IDE , for example lazarus ide :
Project Options -> Compiler Options -> Custom Options
I've done this for a different reason then you and I don't recommend it unless you are a seasoned veteran of writing external libraries. Things like shared memory will be prohibited because the framework wasn't designed with relocatable code in mind. mORMot has a lot of initialization hooks that hook into exceptions, rtti and system units and while there are (some) compile time flags that control this behavior it really goes against the "grain" of the project and may result in unwanted behavior.
That much said, if you don't care about shared memory, mORMot will work just fine in a library after all, without shared memory there's little difference between a program and a library.
For your use case I fail to see why you would want to use a library instead of a normal program, everything you mentioned can be achieved with writing a normal program and in your case there's only disadvantages to using a library instead.
Stay safe Pavlo! Slovenia is a small country but our government and we the people fully support the Ukrainians and your right to exist as a nation. The EU nations must come together on this or EU be damned!
Hard to tell unless you provide a minimal example we can test, tbh I suspect it might be the new httpasync server which is the default in mORMot 2, can you test with the normal http socket server, or if you're using websockets, BidirSocket server.
TRestHttpServer.Create(..., TRestHttpServerUse.useHttpSocket,..l);
You need to provide more info, compiled with Delphi? Which version? Both client and server using same compiler & build mode? Modern Delphi string type is UnicodeString by default UTF-16 encoded so as expected uses more space then UTF-8 encoded rawutf8.
hey, the memory numbers you see in the process tab of the task manager are just a crude approximation of actual memory used. If you have a lot of heap de/allocations like in your case then you are bound to have some heap fragmentation. This means the heap memory will grow over time (but should stabilize) which is what you are observing. There's not much wrong with that since the memory manager will try to reuse the fragmented space.
Absolutely the better way is to use a memory profiler instead of the task manager. If you have to use external software then the better choice is Microsoft's Process Explorer from SysInternals (You would look at the "Private Bytes" statistic of Virtual Memory), but again, it's all just crude approximation.
Currently on mORMot 2, latest revision, can't compile if NOEXCEPTIONINTERCEPT is defined, cheers.
thanks, that works!
that's fine, don't care about the size, I wanted to create a lib (.so) using mormot2 and the linker complained that ../static/x86_64-linux/ecclin64O2.o wasn't compiled with -fPIC so needs to be recompiled. Since I couldn't find the source code it was easier to just switch to openssl to keep the linker happy.
Hi ab , right now the static lib always gets linked even if using openssl instead, can we change this? I think {$define ECC_STATICLIB_AVAILABLE} should be moved to mormot.defines.inc or some other global switch should be made.
thanks ab, I will stick to trunk for now and revert to 3.2.2 if necessary because I don't use variant late bindings.
btw, this forum desperately needs a thumbs up functionality for posts to reduce the amount of "thank you" replies
I've just compiled this example (and my project) successfully with FPC trunk 3.3.1-9066-gffc3e1780d [2021/09/14], so whatever bug seems to have been fixed somewhere after 3.2.2 stable.
FPC 3.2.0-r45643 is over a year old, when fpc team tags next stable release 3.3.x, consider testing mORMot 2 for that revision.
Another thing, since fpc source moved to gitlab, fpcupdeluxe wont accept the svn revision number r45643 because git hashes are now the "revision number", this makes documentation for installing on Linux obsolete.
Initialization is not the problem, in my project I have everything set up correctly with constructor&destructor in a try..finally block and still produces this bug, I also tested it on this MWE example.
It's not that big of a deal tho because nobody should be calling ItemPtr function in production anyway since you can access the original Array directly, however it would be nice if TSynDictionary would have a public function that gives you a pointer to the start of the Keys & Values array respectively.
FPC bug for sure, I just wanted to know if anyone else can reproduce it or if it's just my system that is borked.
the main begin.end block isn't the culprit, this is just a MWE example, I did test it in a sub-procedure originally. I bet the bug has something to do with namespaces , the monolithic unit structure of mORMot 1 didn't trigger this bug on the same compiler version.
I get a linker error when trying to build/compile this simple program
undefined reference to `.Lj14'
program test;
{$I mormot.defines.inc}
uses {$I mormot.uses.inc}
mormot.core.json;
var
P: Pointer;
FDictionary: TSynDictionary;
begin
P := FDictionary.Keys.ItemPtr(0);
end.
Builds OK if ItemPtr Index parameter is > 0.
---------------------------------------------
Debian buster
FPC 3.2.0-r45643
PUREMORMOT2
No optimizations
I also tried on FPC stable 3.2.2.
thx ab, I will be using fpcx64mm as I gradually move over to mORMot 2.
Anyone here who likes to modularize their applications (linux) by writing dynamic libraries? If so, do you use shared memory manager and which one? Any pitfalls and recommendations ?
Upper = Upper of the target parameter? Why?
Because it's faster, reduces the time spent in the lookup table comparing chars.
Next = this is not obvious to me
Moves the string char pointer to the next to be decoded value, this is again performance benefit so it doesn't have to re-scan the entire URL string every time you call UrlDecode functions.
Example:
URL : user=Peter&password=test
if UrlDecodeValue(U, 'USER=', LUser, @U) and UrlDecodeValue(U, 'PASSWORD=', LPassword) then
Contabo is top! I used there services since 2018 without issues.
VPS or dedicated?
those prices at Contabo are just ridiculous, looking at some customer experiences on social sites, the performance seems to be terrible, possibly due to running shoddy hardware and over provisioning multiple users on the same node.