Class: Prosody::ValueState

Inherits:
Object
  • Object
show all
Defined in:
lib/prosody/state.rb,
sig/state.rbs

Overview

--- handles ------------------------------------------------------------ A single-value keyed-state handle. Reads return the stored value or nil. Every op is fiber-yield async: it looks blocking but never blocks the thread.

Instance Method Summary collapse

Constructor Details

#initialize(native) ⇒ ValueState

Returns a new instance of ValueState.

Parameters:



326
327
328
# File 'lib/prosody/state.rb', line 326

def initialize(native)
  @native = native
end

Instance Method Details

#clearvoid

This method returns an undefined value.

Buffers a clear of the value.



345
# File 'lib/prosody/state.rb', line 345

def clear = @native.clear

#commitnil

Durably commits the buffered operations mid-handler.

Returns:

  • (nil)

    the erased FFI seam drops the applied/no-op outcome



350
# File 'lib/prosody/state.rb', line 350

def commit = @native.commit

#getObject? Also known as: value

Reads the current value.

Returns:

  • (Object, nil)

    the stored value, or nil when absent



333
# File 'lib/prosody/state.rb', line 333

def get = @native.get

#rollbacknil

Discards the buffered uncommitted operations.

Returns:

  • (nil)


355
# File 'lib/prosody/state.rb', line 355

def rollback = @native.rollback

#set(value) ⇒ void Also known as: value=

This method returns an undefined value.

Buffers a write of the value.

Parameters:

  • value (Object)

    the value to store (JSON, or a message)

Raises:



340
# File 'lib/prosody/state.rb', line 340

def set(value) = @native.set(value)