mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-06 00:02:08 -04:00
typing the resolvers
This commit is contained in:
parent
7bd9f9a33f
commit
7ba354bcac
@ -1,7 +1,5 @@
|
||||
module HTTPX
|
||||
class Connection
|
||||
type ipaddr = IPAddr | String
|
||||
|
||||
interface _Parser
|
||||
|
||||
def on: (Symbol) { (*untyped) -> void } -> void
|
||||
|
@ -1,6 +1,26 @@
|
||||
module HTTPX
|
||||
type ipaddr = IPAddr | String
|
||||
|
||||
type resolver = Resolver::System | Resolver::Native | Resolver::HTTPS
|
||||
|
||||
|
||||
module Resolver
|
||||
type dns_resource = singleton(Resolv::DNS::Resource)
|
||||
|
||||
type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
|
||||
| { "name" => String, "TTL" => Numeric, "data" => String }
|
||||
|
||||
def self?.cached_lookup: (String hostname) -> Array[String]?
|
||||
|
||||
def self?.cached_lookup_set: (String hostname, Array[dns_result] addresses) -> void
|
||||
|
||||
def self?.uncache: (String hostname) -> void
|
||||
|
||||
def self?.lookup: (String hostname, Numeric ttl) -> Array[String]?
|
||||
|
||||
def self?.generate_id: () -> Integer
|
||||
|
||||
def self?.encode_dns_query: (String hostname, ?type: dns_resource) -> String
|
||||
|
||||
def self?.decode_dns_answer: (String) -> Array[dns_result]
|
||||
end
|
||||
end
|
@ -1,6 +1,49 @@
|
||||
module HTTPX
|
||||
module Resolver
|
||||
class HTTPS
|
||||
include ResolverMixin
|
||||
include _ToIO
|
||||
|
||||
@options: Options
|
||||
@resolver_options: Hash[Symbol, untyped]
|
||||
@_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
|
||||
@queries: Hash[String, Connection]
|
||||
@requests: Hash[Request, Connection]
|
||||
@connections: Array[Connection]
|
||||
@uri: URI::HTTPS
|
||||
@uri_addresses: Array[String]?
|
||||
|
||||
def <<: (Connection) -> void
|
||||
|
||||
def timeout: () -> Numeric?
|
||||
|
||||
def closed?: () -> bool
|
||||
|
||||
def empty?: () -> bool
|
||||
|
||||
def close: () -> void
|
||||
|
||||
def call: () -> void
|
||||
|
||||
def interests: () -> io_interests?
|
||||
|
||||
private
|
||||
|
||||
def initialize: (options) -> untyped
|
||||
|
||||
def pool: () -> Pool
|
||||
|
||||
def resolver_connection: () -> Connection
|
||||
|
||||
def resolve: (Connection, String hostname) -> void
|
||||
| (Connection) -> void
|
||||
| () -> void
|
||||
|
||||
def response: (Response) -> void
|
||||
|
||||
def build_request: (String hostname, "A" | "AAAA") -> Request
|
||||
|
||||
def decode_response_body: (Response) -> Array[dns_result]
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,60 @@
|
||||
module HTTPX
|
||||
module Resolver
|
||||
class Native
|
||||
include ResolverMixin
|
||||
include _ToIO
|
||||
|
||||
@options: Options
|
||||
@ns_index: Integer
|
||||
@resolver_options: Hash[Symbol, untyped]
|
||||
@nameserver: String
|
||||
@_timeouts: Array[Numeric]
|
||||
@timeouts: Hash[String, Array[Numeric]]
|
||||
@_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
|
||||
@connections: Array[Connection]
|
||||
@queries: Hash[String, Connection]
|
||||
@read_buffer: String
|
||||
@write_buffer: Buffer
|
||||
@state: :idle | :closed
|
||||
|
||||
def closed?: () -> bool
|
||||
|
||||
def empty?: () -> bool
|
||||
|
||||
def close: () -> void
|
||||
|
||||
def call: () -> void
|
||||
|
||||
def interests: () -> io_interests
|
||||
|
||||
def <<: (Connection) -> void
|
||||
|
||||
def timeout: () -> Numeric?
|
||||
|
||||
private
|
||||
|
||||
def initialize: (options) -> untyped
|
||||
|
||||
def consume: () -> void
|
||||
|
||||
def do_retry: () -> void
|
||||
|
||||
def dread: (Integer) -> void
|
||||
| () -> void
|
||||
|
||||
def dwrite: () -> void
|
||||
|
||||
def parse: (String) -> void
|
||||
|
||||
def resolve: (Connection, String hostname) -> void
|
||||
| (Connection) -> void
|
||||
| () -> void
|
||||
|
||||
def build_socket: () -> void
|
||||
|
||||
def transition: (Symbol nextstate) -> void
|
||||
|
||||
def handle_error: (StandardError) -> void
|
||||
end
|
||||
end
|
||||
end
|
27
sig/resolver/resolver_mixin.rbs
Normal file
27
sig/resolver/resolver_mixin.rbs
Normal file
@ -0,0 +1,27 @@
|
||||
module HTTPX
|
||||
module Resolver
|
||||
module ResolverMixin
|
||||
include Callbacks
|
||||
include Loggable
|
||||
|
||||
def uncache: (Connection) -> void
|
||||
|
||||
private
|
||||
|
||||
def emit_addresses: (Connection, Array[ipaddr]) -> void
|
||||
|
||||
def early_resolve: (Connection, ?hostname: String) -> void
|
||||
|
||||
def ip_resolve: (String hostname) -> Array[ipaddr]?
|
||||
|
||||
def system_resolve: (String hostname) -> Array[ipaddr]?
|
||||
|
||||
def emit_resolve_error: (Connection, String hostname, StandardError) -> void
|
||||
| (Connection, String hostname) -> void
|
||||
| (Connection) -> void
|
||||
|
||||
def resolve_error: (String hostname, StandardError?) -> void
|
||||
| (String hostname) -> void
|
||||
end
|
||||
end
|
||||
end
|
@ -1,6 +1,17 @@
|
||||
module HTTPX
|
||||
module Resolver
|
||||
class System
|
||||
include ResolverMixin
|
||||
|
||||
def closed?: () -> true
|
||||
|
||||
def empty?: () -> true
|
||||
|
||||
def <<: (Connection) -> void
|
||||
|
||||
private
|
||||
|
||||
def initialize: (options) -> untyped
|
||||
end
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user