Module ocs_rest_pagination_server

Copyright © 2016 - 2026 SigScale Global Inc.

Behaviours: gen_server.

Data Types

continuation()

abstract datatype: continuation()

state()

state() = #state{etag = string(), max_page_size = pos_integer(), timeout = pos_integer(), log = term(), module = atom(), function = atom(), args = list(), cont = continuation(), buffer = [tuple()], offset = non_neg_integer(), length = non_neg_integer(), request = undefined | {StartRange::non_neg_integer(), EndRange::non_neg_integer(), From::gen_server:from()}}

Function Index

start_link/1Start a handler for a sequence of REST range requests.
init/1Initialize the ocs_rest_pagination_server server.
handle_call/3Handle a request sent using gen_server:call/2,3 or gen_server:multi_call/2,3,4.
handle_cast/2Handle a request sent using gen_server:cast/2 or gen_server:abcast/2,3.
handle_info/2Handle a received message.
terminate/2Cleanup and exit.
code_change/3Update internal state data during a release upgrade/downgrade.
range_request/2*Handle a range request.

Function Details

start_link/1

start_link(Args) -> Result

Start a handler for a sequence of REST range requests. Args is a list of [Log, Module, Function, Arguments]. Each request will result in a call to the callback with apply(Module, Function, [Cont | Arguments]). The result should be {Cont, Items} or {error, Reason}. Cont will be start on the first call and the returned value may be eof or an opaque continuation value which will be used in the next call to the callback.

init/1

init(Args) -> Result

Initialize the ocs_rest_pagination_server server.

See also: //stdlib/gen_server:init/1.

handle_call/3

handle_call(Request, From, State) -> Result

Handle a request sent using gen_server:call/2,3 or gen_server:multi_call/2,3,4.

See also: //stdlib/gen_server:handle_call/3.

handle_cast/2

handle_cast(Request, State) -> Result

Handle a request sent using gen_server:cast/2 or gen_server:abcast/2,3.

See also: //stdlib/gen_server:handle_cast/2.

handle_info/2

handle_info(Info, State) -> Result

Handle a received message.

See also: //stdlib/gen_server:handle_info/2.

terminate/2

terminate(Reason, State) -> any()

Cleanup and exit.

See also: //stdlib/gen_server:terminate/3.

code_change/3

code_change(OldVsn, State, Extra) -> Result

Update internal state data during a release upgrade/downgrade.

See also: //stdlib/gen_server:code_change/3.

range_request/2 *

range_request(Range, State) -> Result

Handle a range request. Manages a buffer of items read with the callback.

Reply {Items, ContentRange} on success where Items is a list of collection members and ContentRange is to be used in a Content-Range header. The total items will be included if known at the time (e.g. "items 1-100/*" or "items 50-100/100").

Reply {error, Status} if the request fails. Status is an HTTP status code to be returned to the client.


Generated by EDoc