Class: Nl::Genl::Family

Inherits:
Family
  • Object
show all
Defined in:
nl/lib/nl/genl.rb

Overview

Base class for Generic Netlink families.

Class Method Summary collapse

Class Method Details

.open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY) ⇒ Family .open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY) {|session| ... } ⇒ Object

Opens a session for this Generic Netlink family.

Overloads:

  • .open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY) ⇒ Family

    The caller is responsible for closing the session.

    Parameters:

    • resolver (#call) —

      a callable that resolves a family name to Nl::Genl::FamilyInfo

    • executor (:thread, :fiber, nil) (defaults to: nil) —

      the asynchronous executor, or nil for blocking operation

    • notification_capacity (Integer) (defaults to: DEFAULT_NOTIFICATION_CAPACITY) —

      the maximum number of queued notifications

    Returns:

    • (Family) —

      the opened family session

  • .open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY) {|session| ... } ⇒ Object

    The session is automatically closed after the block returns.

    Parameters:

    • resolver (#call) —

      a callable that resolves a family name to Nl::Genl::FamilyInfo

    • executor (:thread, :fiber, nil) (defaults to: nil) —

      the asynchronous executor, or nil for blocking operation

    • notification_capacity (Integer) (defaults to: DEFAULT_NOTIFICATION_CAPACITY) —

      the maximum number of queued notifications

    Yield Parameters:

    • session (Family) —

      the opened family session

    Returns:

    • (Object) —

      the value returned from the block



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'nl/lib/nl/genl.rb', line 34

def self.open(resolver:, executor: nil, notification_capacity: DEFAULT_NOTIFICATION_CAPACITY)
  begin
    owner = Client.new(resolver:, executor:, notification_capacity:)
    session = owner.family(self).extend(Nl::Family::Session)
  rescue Exception
    owner&.close
    raise
  end
  return session unless block_given?

  begin
    yield session
  ensure
    session.close
  end
end

.version ⇒ Integer

Returns the family-specific protocol version.

Returns:

  • (Integer) —

    the protocol version



15
# File 'nl/lib/nl/genl.rb', line 15

def self.version = self::VERSION