Class: Takagi::ServerRegistry

Inherits:
Object
  • Object
show all
Defined in:
sig/takagi/server_registry.rbs

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.

Examples:

Registering a server

ServerRegistry.register(:udp, Server::Udp)
ServerRegistry.register(:tcp, Server::Tcp)

Building a server

server = ServerRegistry.build(:tcp, port: 5683, worker_threads: 4)

Adding a custom protocol

class MyCustomServer
  def initialize(port:, **options)
    # ...
  end
end
ServerRegistry.register(:custom, MyCustomServer)

Defined Under Namespace

Classes: ProtocolNotFoundError

Class Method Summary collapse

Class Method Details

.buildObject

Build a server instance for the given protocol

Examples:

server = ServerRegistry.build(:tcp, port: 5683, worker_threads: 4)

Parameters:

  • protocol (Symbol)

    Protocol identifier

  • options (Hash)

    Options to pass to server constructor

Returns:

  • (Object)

    Server instance

Raises:



49
# File 'sig/takagi/server_registry.rbs', line 49

def self.build: (untyped protocol, **untyped options) -> untyped

.clear!Object

Clear all registrations (useful for testing)

Returns:

  • (Object)


69
# File 'sig/takagi/server_registry.rbs', line 69

def self.clear!: () -> untyped

.metadata_forHash?

Get metadata for a protocol

Parameters:

  • protocol (Symbol)

    Protocol identifier

Returns:

  • (Hash, nil)

    Metadata hash or nil if not found



66
# File 'sig/takagi/server_registry.rbs', line 66

def self.metadata_for: (untyped protocol) -> untyped

.protocolsArray<Symbol>

Get all registered protocols

Returns:

  • (Array<Symbol>)

    List of protocol identifiers



60
# File 'sig/takagi/server_registry.rbs', line 60

def self.protocols: () -> untyped

.registerObject

Register a server implementation for a protocol

Examples:

ServerRegistry.register(:udp, Server::Udp, rfc: 'RFC 7252')
ServerRegistry.register(:tcp, Server::Tcp, rfc: 'RFC 8323')

Parameters:

  • protocol (Symbol)

    Protocol identifier (:udp, :tcp, :dtls, etc.)

  • klass (Class)

    Server class that responds to .new

  • options (Hash)

    Optional metadata (description, rfc, etc.)

Returns:

  • (Object)


38
# File 'sig/takagi/server_registry.rbs', line 38

def self.register: (untyped protocol, untyped klass, **untyped options) -> untyped

.registered?Boolean

Check if a protocol is registered

Parameters:

  • protocol (Symbol)

    Protocol identifier

Returns:

  • (Boolean)

    true if registered



55
# File 'sig/takagi/server_registry.rbs', line 55

def self.registered?: (untyped protocol) -> untyped