Module espace_server

.

Copyright © 2023, Fred Youhanaie

Behaviours: gen_server.

Authors: Fred Youhanaie (fyrlang@anydata.co.uk).

Description

This is the main admin server for espace instances. It is the custodian of the two ETS tables and replaces the table admin side of the espace_tspace_srv and espace_tspatt_srv servers.

There will be one such server for each instance of espace. The server communicates with the etsmgr server and handles the setup and teardown of the ETS tables during the startup and shutdown phases.

This server does not deal with the data input/output side of espace. The tables are created with public access mode so that individual processes can perform their own input/output operations, see the espace_client module for details.

Function Index

handle_call/3 Handling call messages.
handle_cast/2 Handling cast messages.
handle_continue/2 Handling continue requests.
handle_info/2 Handling all non call/cast messages.
handle_wait4etsmgr/2*wait for etsmgr to (re)start, ensure it manages our ETS table, and update the State data.
init/1 Initializes the server.
start_link/1 Starts the server.
terminate/2 This function is called by a gen_server when it is about to terminate.

Function Details

handle_call/3

handle_call(Request::term(), From::{pid(), term()}, State::term()) -> {reply, Reply::term(), NewState::term()}

Handling call messages

handle_cast/2

handle_cast(Request::term(), State::term()) -> {noreply, NewState::term()}

Handling cast messages

handle_continue/2

handle_continue(Request::term(), State::term()) -> {noreply, term(), hibernate} | {noreply, term(), timeout()} | {noreply, term(), {continue, term()}} | {noreply, term()} | {stop, term(), term()}

Handling continue requests.

We use {continue, init} from espace_server:init/1 to ensure that etsmgr is started and is managing our ETS tables before handling the first request.

handle_info/2

handle_info(Info::timeout() | term(), State::term()) -> {noreply, term()} | {stop, normal | term(), term()}

Handling all non call/cast messages

We can expect an EXIT message if the etsmgr server exits unexpectedly. In this case we need to wait for the new etsmgr server to restart and be told of our ETS table before continuing further.

We can also expect ETS-TRANSFER messages whenever we are handed over the ETS table.

handle_wait4etsmgr/2 *

handle_wait4etsmgr(Mode::atom(), State::term()) -> {ok, term()} | {error, term()}

wait for etsmgr to (re)start, ensure it manages our ETS table, and update the State data.

init/1

init(Inst_name::atom()) -> {ok, term(), {continue, init}}

Initializes the server

start_link/1

start_link(Inst_name::atom()) -> {ok, pid()} | ignore | {error, {already_started, pid()} | term()}

Starts the server.

We expect an instance name to be supplied, which will be used to uniquely identify the ETS table for the instance.

terminate/2

terminate(Reason::term(), State::term()) -> ok

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.


Generated by EDoc