leo_backend_db_server

The gen_server process for the process of database as part of a supervision tree.

Behaviours: `gen_server <gen_server.html>`__.

References

Description

The gen_server process for the process of database as part of a supervision tree

Function Index

close/1 Close the database.
code_change/3 Convert process state when code is changed.
delete/2 Delete an object from backend-db.
fetch/4 Fetch records from backend-db.
finish_compaction/2 Direct to end a compaction.
first/1 Retrieve a first record from backend-db.
get/2 Retrieve an object from backend-db.
get_db_raw_filepath/1 get database file path for calculating disk size.
handle_call/3 gen_server callback - Module:handle_call(Request, From, State) -> Result.
handle_cast/2 gen_server callback - Module:handle_cast(Request, State) -> Result.
handle_info/2 gen_server callback - Module:handle_info(Info, State) -> Result.
init/1 gen_server callback - Module:init(Args) -> Result.
put/3 Insert an object into backend-db.
put_value_to_new_db/3 Direct to put a record to a temporary new data file.
run_compaction/1 Direct to start a compaction.
start_link/3 Creates the gen_server process as part of a supervision tree.
status/1 Retrieve the current status from the database.
stop/1 Close the process.
terminate/2 This function is called by a gen_server when it is about to terminate.

Function Details

close/1

close(Id) -> ok

  • Id = atom()

Close the database

code_change/3

code_change(OldVsn, State, Extra) -> any()

Convert process state when code is changed

gen_server callback - Module:code_change(OldVsn, State, Extra) -> {ok, NewState} | {error, Reason}.

delete/2

delete(Id::atom(), KeyBin::binary()) -> ok | {error, any()}

Delete an object from backend-db.

fetch/4

fetch(Id, KeyBin, Fun, MaxKeys) -> {ok, list()} | not_found | {error, any()}

  • Id = atom()
  • KeyBin = binary()
  • Fun = function()
  • MaxKeys = integer()

Fetch records from backend-db.

finish_compaction/2

finish_compaction(Id, Commit) -> ok | {error, any()}

  • Id = atom()
  • Commit = boolean()

Direct to end a compaction.

first/1

first(Id) -> {ok, any(), any()} | {error, any()}

  • Id = atom()

Retrieve a first record from backend-db.

get/2

get(Id, KeyBin) -> {ok, binary()} | not_found | {error, any()}

  • Id = atom()
  • KeyBin = binary()

Retrieve an object from backend-db.

get_db_raw_filepath/1

get_db_raw_filepath(Id) -> {ok, string()} | {error, any()}

  • Id = atom()

get database file path for calculating disk size.

handle_call/3

handle_call(X1, From, State) -> any()

gen_server callback - Module:handle_call(Request, From, State) -> Result

handle_cast/2

handle_cast(Msg, State) -> any()

gen_server callback - Module:handle_cast(Request, State) -> Result

handle_info/2

handle_info(Info, State) -> any()

gen_server callback - Module:handle_info(Info, State) -> Result

init/1

init(X1) -> any()

gen_server callback - Module:init(Args) -> Result

put/3

put(Id, KeyBin, ValueBin) -> ok | {error, any()}

  • Id = atom()
  • KeyBin = binary()
  • ValueBin = binary()

Insert an object into backend-db.

put_value_to_new_db/3

put_value_to_new_db(Id, KeyBin, ValueBin) -> ok | {error, any()}

  • Id = atom()
  • KeyBin = binary()
  • ValueBin = binary()

Direct to put a record to a temporary new data file.

run_compaction/1

run_compaction(Id) -> ok | {error, any()}

  • Id = atom()

Direct to start a compaction.

status/1

status(Id) -> [{atom(), term()}]

  • Id = atom()

Retrieve the current status from the database

stop/1

stop(Id) -> any()

Close the process

terminate/2

terminate(Reason, State) -> any()

This function is called by a gen_server when it is about to terminate. It should be the opposite of Module:init/1 and do any necessary cleaning up. When it returns, the gen_server terminates with Reason. The return value is ignored.

gen_server callback - Module:terminate(Reason, State)