'\" t .\" This documentation, which is part of the afnix writing .\" system distribution, is free and can be distributed as .\" long as this copyright notice is left intact. .\" .\" This documentation is distributed in the hope that it .\" will be useful, but without any warranty; without even .\" the implied warranty of merchantability and fitness .\" for a particular purpose. In no event, shall the .\" copyright holder be liable for any direct, incident .\" incidental or special damages arising in any way out .\" of the use of this documentation. .\" .\" Copyright (c) 1999-2017 Amaury Darsch .\" .TH csm 3 2018-07-20 AFNIX "AFNIX Service" .SH NAME csm - standard cloud session management service .SH STANDARD CLOUD SESSION MANAGEMENT SERVICE The Standard Cloud Session Managementservice is an original implementation of various objects dedicated to the management of events eventually associated with a session controller. In its classical way, the objects can be used to manage an agenda, schedule events and perform associated actions. In a more elaborated way, a session group can be used to manage different group of objects bound to one or several users or groups. .PP .B General concepts .br The afnix-csmprovides the support for manipulating cloud session data. Information data are generally personal information that are used to manage time and constraints or global session information bound to one or several users. In the time domain, the session management is related to the concept of time slot and agenda. .PP .I Slot .br The concept of slot is central in the csmservice. A slot is a combination of time and duration. A slot is allocated by an appointer to indicate the next available slot. For an agenda, the concept of slot can be derived to describe an appointment. .PP .I Appointer .br An appointeris a slot generator. The appointer can be designed to respond automatically with respect to a certain number of rules. Common rules found in an appointer are closed days like week-end and time allocation period. .PP .I Assistant .br An assistantis a combination of csm object like appointers. An assistant can be used for example, to manage several appointers. .PP .B Appointer operations .br The Appointerclass is designed to allocate slots with respect to a certain duration or from a certain time with a duration. The appointer operates with rules which describe the operating calendar and daily schedule. such rules are designed to mimic real-life situations like week-end blocked days or Christmas vacation day. .PP .I Slot allocation .br A slot is allocated with the get-slotmethod. This method is common to the Appointerand Assistantclasses. .sp .nf # allocate a 1 hour slot const slot (appt:get-slot 3600) .fi .sp In the example above, a 1 hour slot is allocated at the current appointer time. Note that the time and duration are always given in seconds. If the slot needs to be allocated starting at a certain time, the 2 arguments form can be used. .sp .nf # allocate a 1 hour slot starting at 2AM const slot (appt:get-slot 7200 3600) .fi .sp In the presence of an Assistantobject the get-slotis the same but selects the appropriate appointer with the help of an internal index which rotated after each call. This method permits an equal distribution for all appointers within an assistant. .PP .I Appointer rules .br There are basically, two types of appointer's rules. The first type of rule is used for blocking a day as a whole. The second type of rule is designed to describe valid periods of allocation time. The first type of rules is called the and rulessince all rules must be valid in order to allocate a slot at the requested time. The second type is a called the or rulessince only one rule needs to be valid in order to allocate a slot. .sp .nf # create a reference appointer const appt (afnix:csm:Appointer) # add a saturday and sunday blocked day rule appt:set-blocked-day 6 appt:set-blocked-day 0 # set the special days appt:set-special-day 1 1 appt:set-special-day 12 25 .fi .sp The example above defines an appointer object. The first 2 rules defines Saturday and Sunday as blocked days. The other 2 rules, defines Jan 1st and Dec 25th as special days. No slot can be allocated in a blocked or special day. .sp .nf # set a valid block time between 8AM to 12AM const ambt (* 3600 8) const amet (* 3600 12) const pmbt (* 3600 14) # set a valid block time between 2PM to 6PM const pmet (* 3600 18) appt:set-valid-block-time ambt amet appt:set-valid-block-time pmbt pmet .fi .sp the above example defines two valid periods for allocating time. The first period runs from 8AM to 12AM and the second one runs from 2PM to 6PM. Note that the time is also expressed in second. The time arguments are always rounded to the maximum number of seconds per day. .PP .B Assistant operations .br An assistant object is build by adding object to it. In general, a reference object is created, and several of them are added to the assistant by cloning the reference object. .PP .I Assistant integration .br Once an assistant object has been created, the object can be added by cloning. .sp .nf # create an assistant const name "Mr Smith" const info "The super assistant" const asst (afnix:csm:Assistant name info) # create a reference appointer const appt (afnix:csm:Appointer) # add 2 appointers by cloning asst:add-appointer (appt:clone) asst:add-appointer (appt:clone) .fi .sp In the case of an Appointerobject, the appointer is cloned with all its rules attached to it. This method is particularly useful when an assistant needs to be setup for several person that shares the same calendar. .SH STANDARD CLOUD SESSION MANAGEMENT REFERENCE .PP .B Slot .br The Slotclass is a base class designed to handle a basic time slot event. The class is defined with a date and a duration. The slot class is primarily used to build an agenda. .PP .I Predicate .br .sp .RS slot-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B Slot (none) .br The Slotconstructor creates an empty slot initialized at time 0 with duration 0. .RE .sp .RS .B Slot (Integer Integer) .br The Slotconstructor creates a slot with a time and duration. The first argument is the slot time. The second argument is the slot duration. .RE .PP .I Methods .br .sp .RS .B reset -> none (none) .br The resetmethod reset the slot to time 0 with duration 0. .RE .sp .RS .B set-time -> none (Integer) .br The set-timemethod sets the slot time. .RE .sp .RS .B get-time -> Integer (none) .br The get-timemethod returns the slot time. .RE .sp .RS .B set-duration -> none (Integer) .br The set-durationmethod sets the slot duration. .RE .sp .RS .B get-duration -> Integer (none) .br The get-durationmethod returns the slot duration. .RE .sp .RS .B set-slot -> none (Integer Integer) .br The set-slotmethod sets the slot time and duration at once. The first argument is the slot time. The second argument is the slot duration. .RE .PP .B Appointer .br The Appointerclass is a class design to allocate time slot in a calendar in order to fill an agenda. The appointer do not store the slot but rather acts as a generator. the appointer algorithm operates with rules that permits to allocate the next available slot. The basic rules permits to define regular blocked days and special blocked days. Another rule permits to define an operating time period. Multiple time periods are allowed. A maximum daily slots rule is also available. .PP .I Predicate .br .sp .RS appointer-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B Appointer (none) .br The Appointerconstructor creates a default appointer initialized at time 0. There is no rule installed by the constructor. .RE .sp .RS .B Appointer (Integer) .br The Appointerconstructor creates an appointer with an initial time. The time is set as he starting time to allocate slots. There is no rule installed by the constructor. .RE .PP .I Methods .br .sp .RS .B reset -> none (none) .br The resetmethod reset the appointer slot number and daily slot counter. The rules are not touched by this method. .RE .sp .RS .B set-time -> none (Integer) .br The set-timemethod set the appointer time. During the next operation, the newly allocated slots have their time starting at least at this time. .RE .sp .RS .B get-time -> Integer (none) .br The get-timemethod returns the current appointer time. .RE .sp .RS .B set-date -> none (Date) .br The set-datemethod set the appointer time by converting the date argument to a time. .RE .sp .RS .B get-date -> Integer (none) .br The get-datemethod returns the current appointer date. .RE .sp .RS .B get-slot -> Slot (Integer|Integer Integer) .br The get-slotmethod returns a new slot allocated by the appointer. with one argument the argument is taken as the slot duration. With 2 arguments, the first arguments is the requested slot time and the second argument is the slot duration. The slot allocation algorithm operates by finding the appropriate day and time which satisfies the appointer rules. If the slot cannot be found within one week, the allocation is assumed to have failed. .RE .sp .RS .B get-slot-number -> Integer (none) .br The get-slot-numbermethod returns the total number of slots allocated by the appointer. .RE .sp .RS .B set-blocked-day -> none (Integer) .br The set-blocked-daymethod sets a regular weekly block day. The method uses the week day index as its argument. Sunday has index 0 and Saturday has index 6. No slot is allocated in a blocked day. .RE .sp .RS .B set-special-day -> none (Integer Integer) .br The set-special-daymethod sets a special year day. The method uses the year month and the month day index as its arguments. The first argument is the year month which must be in the range of 1 to 12. The second argument is the month day which must be in the range of 1 to 31. No slot is allocated in a special day. .RE .sp .RS .B set-maximum-slots -> none (Integer) .br The set-maximum-slotsmethod sets a daily maximum slots number. When the daily maximum slot number is reached, the slot allocation proceed to the next day. .RE .sp .RS .B set-valid-block-time -> none (Integer Integer) .br The set-valid-block-timemethod sets a valid block time in which the slot can be allocated. By default, a slot can be allocated anytime during the day. When this rule is set, at least once, the slot is allocated in this block. Multiple valid block time can be defined. The first argument is the valid block time lower bound expressed in seconds from 12PM. The second argument is the valid block time upper bound. All time are expressed in seconds and rounded to a day second which is 84600 seconds in 24 hours. For example, a valid block time is from 8AM to 12AM. Another would be from 2PM to 6PM. .RE .PP .B Assistant .br The Assistantclass class is a generic class designed to hold various csm component and manage them like an assistant will do. For example, the class can store several Appointerobjects and distribute slot for all of them. .PP .I Predicate .br .sp .RS assistant-p .RE .PP .I Inheritance .br .sp .RS Object .RE .PP .I Constructors .br .sp .RS .B Assistant (none) .br The Assistantconstructor creates a default assistant. .RE .sp .RS .B Assistant (String) .br The Assistantconstructor creates a default assistant by name. .RE .sp .RS .B Assistant (String String) .br The Assistantconstructor creates a default assistant by name and information. The first argument is the assistant name. the second argument is the assistant information string. .RE .PP .I Methods .br .sp .RS .B reset -> none (none) .br The resetmethod reset the assistant by. All objects attached to the assistant are reset by this method. .RE .sp .RS .B get-name -> String (none) .br The get-namemethod returns the assistant name. .RE .sp .RS .B get-info -> String (none) .br The get-infomethod returns the assistant information string. .RE .sp .RS .B pushback -> none (Slot) .br The pushbackmethod pushbaks a slot in the appointer list. The assistant manages internally an index which is used to select the appointer where the slot is pushed-back. .RE .sp .RS .B get-slot -> Slot (Integer|Integer Integer) .br The get-slotmethod returns he next available slot from the appointer list. The assistant manages internally an index which is used to select the appointer from which the slot is obtained. With one argument, the method operates with a slot duration. with 2 arguments, the method operates by time and duration. The time is the minimum time for which the slot is allocated. If the slot cannot be allocated, an exception is raised. .RE .sp .RS .B add-appointer -> none (Appointer) .br The add-appointermethod adds an appointer object to the assistant. .RE .sp .RS .B get-appointer -> Appointer (Integer) .br The get-appointermethod returns an appointer object by index. If the appointer object cannot be found, an exception is raised. .RE .sp .RS .B length-appointer -> Integer (none) .br The length-appointermethod returns the number of appointers attached to the assistant. .RE .sp .RS .B get-slot-number -> Integer (none) .br The get-slot-numbermethod returns the total number of slot allocated by the assistant at the time of the call. The number is computed by summing all slot numbers for each appointers. attached to the assistant. .RE .sp .RS .B get-appointer-time -> Integer (none) .br The get-appointer-timemethod returns the average appointer time for the attached appointers. At the time of the call, each appointer has a time which corresponds to the next slot available time. The average time for all appointers is the result of this method which corresponds to the average time of the next available slot. .RE .PP .B Session .br The Sessionclass that defines a session to be associated with a cloud transaction. The session object is designed to be persistent so that its data information can be retrieved at any time. A session object has also the particularity to have a limited lifetime. A session object is created by name with an identifier. If a path is given, such path will be used as the session file name. .PP .I Predicate .br .sp .RS session-p .RE .PP .I Inheritance .br .sp .RS Serial .RE .PP .I Constructors .br .sp .RS .B Session (String) .br The Sessionconstructor creates a session by name. The string argument is the session name. .RE .sp .RS .B Session (String String) .br The Sessionconstructor creates a session with a name and a user. The first argument is the session name. The second argument is the user name. .RE .sp .RS .B Session (String String Integer) .br The Sessionconstructor creates a session with a name, a user and a maximum age. The first argument is the session name. The second argument is the session user name. The third argument is the session maximum age expressed in seconds. .RE .PP .I Methods .br .sp .RS .B expire-p -> Boolean (none) .br The expire-ppredicate returns true if the session has expired. .RE .sp .RS .B get-name -> String (none) .br The get-namemethod returns the session name. .RE .sp .RS .B set-user -> none (String) .br The set-usermethod sets the session user name. .RE .sp .RS .B get-session-rid -> String (none) .br The get-session-ridmethod returns the session rid. .RE .sp .RS .B set-session-rid -> none (String) .br The set-session-ridmethod sets the session rid. .RE .sp .RS .B get-user -> String (none) .br The get-usermethod returns the session user name. .RE .sp .RS .B set-hash-id -> none (String) .br The set-hash-idmethod sets the session hash identifier. The session hash id must be unique and secured enough so that the session name cannot be derived from it. .RE .sp .RS .B get-hash-id -> String (none) .br The get-hash-idmethod returns the session hash identifier. .RE .sp .RS .B set-path -> none (String) .br The set-pathmethod sets the session path. .RE .sp .RS .B get-path -> String (none) .br The get-pathmethod returns the session path. .RE .sp .RS .B get-max-age -> Integer (none) .br The get-max-agemethod returns the session maximum age. .RE .sp .RS .B set-max-age -> none (Integer) .br The set-max-agemethod sets the session maximum age. The maximum age is an integer in seconds relative to the current time. If the maximum age is set to 0, the session is closed. .RE .sp .RS .B get-remaining-time -> Integer (none) .br The get-remaining-timemethod returns the remaining valid session time. .RE .sp .RS .B get-expire-time -> Integer (none) .br The get-expire-timemethod returns the session expiration time in seconds. The expiration time is an absolute time. .RE .sp .RS .B set-expire-time -> none (Integer) .br The set-expire-timemethod sets the session expiration time. The expiration time is an absolute time in seconds. .RE .sp .RS .B get-creation-time -> Integer (none) .br The get-creation-timemethod returns the session creation time. The creation time is an absolute time in seconds. .RE .sp .RS .B get-modification-time -> Integer (none) .br The get-modification-timemethod returns the session creation time. The modification time is an absolute time in seconds. .RE .sp .RS .B get-cookie -> Cookie (name) .br The get-cookiemethod bakes a session cookie. The string argument is the cookie name those value is the session hash id value. .RE .sp .RS .B close -> Cookie (name) .br The closemethod close a session by reseting the session maximum age to 0. The method returns a cookie that can be used for closing the session on the peer side. The string argument is the cookie name those value is the session hash id value. .RE