Class: Nl::Genl::Client
- Inherits:
-
Object
- Object
- Nl::Genl::Client
- Defined in:
- nl/lib/nl/genl/client.rb
Overview
Owns one generic Netlink connection shared by compatible families.
Class Method Summary collapse
-
.open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Object
Opens a generic Netlink client.
Instance Method Summary collapse
-
#close ⇒ void
Closes the underlying Netlink connection.
-
#family(family_class) ⇒ Family
Builds a family backed by this client's connection.
-
#initialize(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client
Returns a new instance of Client.
54 55 56 57 58 59 60 61 62 63 |
# File 'nl/lib/nl/genl/client.rb', line 54 def initialize(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) @resolver = resolver @family_cache = {} @family_cache_mutex = Mutex.new @connection = Nl::Connection.new( protocol: Protocol.new, executor:, notification_capacity:, ) end |
Class Method Details
.open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) ⇒ Client .open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) {|client| ... } ⇒ Object
Opens a generic Netlink client.
39 40 41 42 43 44 45 46 47 48 |
# File 'nl/lib/nl/genl/client.rb', line 39 def self.open(resolver:, executor: nil, notification_capacity: Nl::Connection::DEFAULT_NOTIFICATION_CAPACITY) client = new(resolver:, executor:, notification_capacity:) return client unless block_given? begin yield client ensure client.close end end |
Instance Method Details
#close ⇒ void
This method returns an undefined value.
Closes the underlying Netlink connection.
87 88 89 |
# File 'nl/lib/nl/genl/client.rb', line 87 def close @connection.close end |
#family(family_class) ⇒ Family
Builds a family backed by this client's connection.
71 72 73 74 75 76 77 78 79 80 81 |
# File 'nl/lib/nl/genl/client.rb', line 71 def family(family_class) unless family_class <= Family raise TypeError, "family class must inherit from #{Family}" end info = family_info(family_class::NAME) family_class.new( @connection, endpoint: Endpoint.new(family_class, info), ) end |