Skip to content

Commit

Permalink
Merge pull request #9480 from pavelmash/mormot/pipelineRefactoring
Browse files Browse the repository at this point in the history
[mORMot] - upgrade to [email protected] with HTTP pipelining mode improvements
  • Loading branch information
msmith-techempower authored Jan 6, 2025
2 parents a8e50c5 + 0e9ad23 commit 0ec940b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion frameworks/Pascal/mormot/setup_and_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ echo "Download statics from $URL ..."
wget -qO- "$URL" | tar -xz -C ./libs/mORMot/static

# uncomment for fixed commit URL
URL=https://github.com/synopse/mORMot2/tarball/2017bddac17a838c9584763e4bd7538aa6f8a529
URL=https://github.com/synopse/mORMot2/tarball/53bee75f81062db0700c97dfa9dfb5e9ce408679
#URL="https://api.github.com/repos/synopse/mORMot2/tarball/$USED_TAG"
echo "Download and unpacking mORMot sources from $URL ..."
wget -qO- "$URL" | tar -xz -C ./libs/mORMot --strip-components=1
Expand Down
24 changes: 8 additions & 16 deletions frameworks/Pascal/mormot/src/raw.pas
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ function TRawAsyncServer.json(ctxt: THttpServerRequest): cardinal;
msgRec: TMessageRec;
begin
msgRec.message := pointer(HELLO_WORLD);
ctxt.SetOutJson(@msgRec, TypeInfo(TMessageRec));
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(@msgRec, TypeInfo(TMessageRec));
end;

function TRawAsyncServer.db(ctxt: THttpServerRequest): cardinal;
Expand All @@ -329,8 +328,7 @@ function TRawAsyncServer.db(ctxt: THttpServerRequest): cardinal;
begin
w := TOrmWorld.Create(fStore.Orm, ComputeRandomWorld(Lecuyer));
try
ctxt.SetOutJson(w);
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(w);
finally
w.Free;
end;
Expand All @@ -346,9 +344,8 @@ function TRawAsyncServer.queries(ctxt: THttpServerRequest): cardinal;
gen := Lecuyer;
for i := 0 to length(res) - 1 do
res[i] := TOrmWorld.Create(fStore.Orm, ComputeRandomWorld(gen));
ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
result := ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
ObjArrayClear(res);
result := HTTP_SUCCESS;
end;

function TRawAsyncServer.cached_queries(ctxt: THttpServerRequest): cardinal;
Expand All @@ -361,8 +358,7 @@ function TRawAsyncServer.cached_queries(ctxt: THttpServerRequest): cardinal;
gen := Lecuyer;
for i := 0 to length(res) - 1 do
res[i] := fOrmCache.Get(ComputeRandomWorld(gen));
ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
end;

function OrmFortuneCompareByMessage(const A, B): integer;
Expand Down Expand Up @@ -436,9 +432,8 @@ function TRawAsyncServer.rawdb(ctxt: THttpServerRequest): cardinal;
stmt.ExecutePrepared;
if stmt.Step then
begin
ctxt.SetOutJson(
result := ctxt.SetOutJson(
'{"id":%,"randomNumber":%}', [stmt.ColumnInt(0), stmt.ColumnInt(1)]);
result := HTTP_SUCCESS;
stmt.ReleaseRows;
end;
stmt := nil;
Expand All @@ -450,8 +445,7 @@ function TRawAsyncServer.rawqueries(ctxt: THttpServerRequest): cardinal;
begin
if not GetRawRandomWorlds(GetQueriesParamValue(ctxt), res) then
exit(HTTP_SERVERERROR);
ctxt.SetOutJson(@res, TypeInfo(TWorlds));
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(@res, TypeInfo(TWorlds));
end;

function TRawAsyncServer.rawcached(ctxt: THttpServerRequest): cardinal;
Expand All @@ -464,8 +458,7 @@ function TRawAsyncServer.rawcached(ctxt: THttpServerRequest): cardinal;
gen := Lecuyer;
for i := 0 to length(res) - 1 do
res[i] := fRawCache[ComputeRandomWorld(gen) - 1];
ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(@res, TypeInfo(TOrmWorlds));
end;

function TRawAsyncServer.rawfortunes(ctxt: THttpServerRequest): cardinal;
Expand Down Expand Up @@ -555,8 +548,7 @@ function TRawAsyncServer.rawupdates(ctxt: THttpServerRequest): cardinal;
end;
end;
stmt.ExecutePrepared;
ctxt.SetOutJson(@res, TypeInfo(TWorlds));
result := HTTP_SUCCESS;
result := ctxt.SetOutJson(@res, TypeInfo(TWorlds));
end;

// asynchronous PostgreSQL pipelined DB access
Expand Down

0 comments on commit 0ec940b

Please sign in to comment.