Class: Legate::SessionService::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/legate/session_service/base.rb

Overview

Base class for session services

Direct Known Subclasses

ActiveRecord, InMemory

Instance Method Summary collapse

Instance Method Details

#append_event(session_id:, event:) ⇒ Object

Raises:

  • (NotImplementedError)


40
41
42
# File 'lib/legate/session_service/base.rb', line 40

def append_event(session_id:, event:)
  raise NotImplementedError, "#{self.class.name} must implement #append_event."
end

#clear_scoped_state(scope, key) ⇒ Object

Clears scoped state

Parameters:

  • scope (String)

    The scope of the state (‘user’, ‘app’, or ‘temp’)

  • key (String)

    The key to clear

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



36
37
38
# File 'lib/legate/session_service/base.rb', line 36

def clear_scoped_state(scope, key)
  raise NotImplementedError, "#{self.class} must implement #clear_scoped_state"
end

#get_state(session_id:, key:) ⇒ Object?

Retrieves a value from the state associated with the session. This typically involves finding the session and then calling the session object’s own state management methods (e.g., session.get_state(key)).

Parameters:

  • session_id (String)

    The ID of the session.

  • key (Symbol)

    The key for the state entry (should not have service-level prefixes).

Returns:

  • (Object, nil)

    The value if found, or nil.

Raises:

  • (NotImplementedError)

    If the subclass does not implement this method.



63
64
65
# File 'lib/legate/session_service/base.rb', line 63

def get_state(session_id:, key:)
  raise NotImplementedError, "#{self.class.name} must implement #get_state."
end

#load_scoped_state(scope, key) ⇒ Object?

Loads scoped state

Parameters:

  • scope (String)

    The scope of the state (‘user’, ‘app’, or ‘temp’)

  • key (String)

    The key to load

Returns:

  • (Object, nil)

    The loaded value or nil if not found

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



28
29
30
# File 'lib/legate/session_service/base.rb', line 28

def load_scoped_state(scope, key)
  raise NotImplementedError, "#{self.class} must implement #load_scoped_state"
end

#persistent?Boolean

Returns whether this service persists state

Returns:

  • (Boolean)

    true if state is persisted, false otherwise



10
11
12
# File 'lib/legate/session_service/base.rb', line 10

def persistent?
  false
end

#save_scoped_state(scope, key, value) ⇒ Object

Saves scoped state

Parameters:

  • scope (String)

    The scope of the state (‘user’, ‘app’, or ‘temp’)

  • key (String)

    The key to save

  • value (Object)

    The value to save

Raises:

  • (NotImplementedError)

    Must be implemented by subclasses



19
20
21
# File 'lib/legate/session_service/base.rb', line 19

def save_scoped_state(scope, key, value)
  raise NotImplementedError, "#{self.class} must implement #save_scoped_state"
end

#set_state(session_id:, key:, value:) ⇒ void

This method returns an undefined value.

Sets a key-value pair in the state associated with the session. This typically involves finding the session and then calling the session object’s own state management methods (e.g., session.set_state(key, value)).

Parameters:

  • session_id (String)

    The ID of the session.

  • key (Symbol)

    The key for the state entry (should not have service-level prefixes like user: or app:).

  • value (Object)

    The value to store.

Raises:

  • (NotImplementedError)

    If the subclass does not implement this method.



52
53
54
# File 'lib/legate/session_service/base.rb', line 52

def set_state(session_id:, key:, value:)
  raise NotImplementedError, "#{self.class.name} must implement #set_state."
end