| 1 |
|
%% Copyright (c) 2023 Peter Morgan <peter.james.morgan@gmail.com> |
| 2 |
|
%% |
| 3 |
|
%% Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
|
%% you may not use this file except in compliance with the License. |
| 5 |
|
%% You may obtain a copy of the License at |
| 6 |
|
%% |
| 7 |
|
%% http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
|
%% |
| 9 |
|
%% Unless required by applicable law or agreed to in writing, software |
| 10 |
|
%% distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
|
%% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
|
%% See the License for the specific language governing permissions and |
| 13 |
|
%% limitations under the License. |
| 14 |
|
|
| 15 |
|
|
| 16 |
|
-module(pgec_storage_sync). |
| 17 |
|
|
| 18 |
|
|
| 19 |
|
-export([delete/1]). |
| 20 |
|
-export([keys/1]). |
| 21 |
|
-export([metadata/1]). |
| 22 |
|
-export([position/1]). |
| 23 |
|
-export([position_update/1]). |
| 24 |
|
-export([read/1]). |
| 25 |
|
-export([table_map/1]). |
| 26 |
|
-export([write/1]). |
| 27 |
|
|
| 28 |
|
|
| 29 |
|
keys(Arg) -> |
| 30 |
34 |
receive_response(?FUNCTION_NAME, Arg). |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
position(Arg) -> |
| 34 |
:-( |
receive_response(?FUNCTION_NAME, Arg). |
| 35 |
|
|
| 36 |
|
|
| 37 |
|
position_update(Arg) -> |
| 38 |
:-( |
receive_response(?FUNCTION_NAME, Arg). |
| 39 |
|
|
| 40 |
|
|
| 41 |
|
read(Arg) -> |
| 42 |
97 |
receive_response(?FUNCTION_NAME, Arg). |
| 43 |
|
|
| 44 |
|
|
| 45 |
|
delete(Arg) -> |
| 46 |
:-( |
receive_response(?FUNCTION_NAME, Arg). |
| 47 |
|
|
| 48 |
|
|
| 49 |
|
write(Arg) -> |
| 50 |
:-( |
receive_response(?FUNCTION_NAME, Arg). |
| 51 |
|
|
| 52 |
|
|
| 53 |
|
table_map(Arg) -> |
| 54 |
:-( |
receive_response(?FUNCTION_NAME, Arg). |
| 55 |
|
|
| 56 |
|
|
| 57 |
|
metadata(Arg) -> |
| 58 |
72 |
receive_response(?FUNCTION_NAME, Arg). |
| 59 |
|
|
| 60 |
|
|
| 61 |
|
receive_response(Function, Arg) -> |
| 62 |
203 |
M = pgec_storage, |
| 63 |
203 |
case gen_statem:receive_response( |
| 64 |
|
M:Function( |
| 65 |
|
maps:merge( |
| 66 |
|
#{server_ref => M}, |
| 67 |
|
Arg))) of |
| 68 |
|
{reply, Reply} -> |
| 69 |
203 |
Reply; |
| 70 |
|
|
| 71 |
|
{error, _} = Error -> |
| 72 |
:-( |
Error |
| 73 |
|
end. |