Class: Myrr::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/myrr/configuration.rb

Overview

Configuration for the myrr-rb gem.

In its default (Port) state the gem requires zero configuration. Token counting on text/markdown responses and the X-Token-Count header are active out of the box.

Additional attributes exist for the opt-in identity and pay layers (not auto-loaded — require explicitly).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



47
48
49
50
51
52
53
54
55
56
# File 'lib/myrr/configuration.rb', line 47

def initialize
  # Identity-layer defaults (nil / conservative — opt-in only)
  @protocol_server_url = nil
  @site_api_key = nil
  @identity_adapter = nil
  @fail_open = true
  @auto_format_md = false
  @open_timeout = 5
  @read_timeout = 10
end

Instance Attribute Details

#auto_format_mdBoolean

When true, the identity middleware auto-selects :md format when an agent is detected and no explicit format is set. Default is false (port mode does not negotiate format).

Returns:

  • (Boolean)


37
38
39
# File 'lib/myrr/configuration.rb', line 37

def auto_format_md
  @auto_format_md
end

#fail_openBoolean

When true (default), requests proceed when identity verification fails (logging a warning). When false, returns 502 Bad Gateway.

Returns:

  • (Boolean)


31
32
33
# File 'lib/myrr/configuration.rb', line 31

def fail_open
  @fail_open
end

#identity_adapterProc?

Optional lambda that replaces protocol server calls for identity verification. Receives a did:myrr: string, returns a hash with did_key, status, and optional owner, or nil.

Returns:

  • (Proc, nil)


26
27
28
# File 'lib/myrr/configuration.rb', line 26

def identity_adapter
  @identity_adapter
end

#open_timeoutInteger

HTTP open timeout in seconds.

Returns:

  • (Integer)


41
42
43
# File 'lib/myrr/configuration.rb', line 41

def open_timeout
  @open_timeout
end

#protocol_server_urlString?

URL of the Myrr protocol server (e.g. "http://localhost:8080"). Required when using the identity or pay layers.

Returns:

  • (String, nil)


16
17
18
# File 'lib/myrr/configuration.rb', line 16

def protocol_server_url
  @protocol_server_url
end

#read_timeoutInteger

HTTP read timeout in seconds.

Returns:

  • (Integer)


45
46
47
# File 'lib/myrr/configuration.rb', line 45

def read_timeout
  @read_timeout
end

#site_api_keyString?

API key for authenticating with the protocol server.

Returns:

  • (String, nil)


20
21
22
# File 'lib/myrr/configuration.rb', line 20

def site_api_key
  @site_api_key
end