Class: Takagi::Server::Registry
- Inherits:
-
Object
- Object
- Takagi::Server::Registry
- Extended by:
- Registry::Base
- Defined in:
- lib/takagi/server/registry.rb
Overview
Registry for CoAP server implementations
Allows registering different protocol implementations (UDP, TCP, DTLS, QUIC, etc.) without modifying core code. Follows the Open/Closed Principle.
Uses Registry::Base for thread-safe storage and consistent API.
Defined Under Namespace
Classes: ProtocolNotFoundError
Class Method Summary collapse
-
.build(protocol, **options) ⇒ Object
Build a server instance for the given protocol.
-
.protocols ⇒ Array<Symbol>
Get all registered protocols.
-
.register(protocol, klass, **metadata) ⇒ Object
Register a server implementation for a protocol.
Methods included from Registry::Base
[], clear!, count, each, empty?, entries, extended, get, keys, metadata_for, register, registered?, unregister
Class Method Details
.build(protocol, **options) ⇒ Object
Build a server instance for the given protocol
55 56 57 58 59 60 |
# File 'lib/takagi/server/registry.rb', line 55 def build(protocol, **) klass = get(protocol.to_sym) klass.new(**) rescue Takagi::Registry::Base::NotFoundError => e raise ProtocolNotFoundError, "Unknown protocol: #{protocol}" end |
.protocols ⇒ Array<Symbol>
Get all registered protocols
65 66 67 |
# File 'lib/takagi/server/registry.rb', line 65 def protocols keys end |
.register(protocol, klass, **metadata) ⇒ Object
Register a server implementation for a protocol
42 43 44 |
# File 'lib/takagi/server/registry.rb', line 42 def register(protocol, klass, **) super(protocol.to_sym, klass, **) end |