Skip to content

create unix-socket example#324

Open
ggmichaelgo wants to merge 1 commit intosocketry:mainfrom
ggmichaelgo:unix-socket-example
Open

create unix-socket example#324
ggmichaelgo wants to merge 1 commit intosocketry:mainfrom
ggmichaelgo:unix-socket-example

Conversation

@ggmichaelgo
Copy link

Create a unix-socket Falcon server example

Types of Changes

  • Maintenance.

Contribution

@samuel-williams-shopify
Copy link
Contributor

The client is okay but would it be better to show how to use the endpoint mechanism:

require 'io/endpoint/unix_endpoint'
endpoint = Async::HTTP::Endpoint.parse("http://localhost:9292", endpoint: IO::Endpoint.unix("http.ipc"))
# => #<Async::HTTP::Endpoint http://localhost:9292/ {endpoint: #<IO::Endpoint::UNIXEndpoint path="http.ipc">}>

# Just for the sake of running this in irb:
Async{binding.irb}

server = Async::HTTP::Server.for(endpoint) do |request|
  Protocol::HTTP::Response[200]
end
# => #<Async::HTTP::Server:0x000000012ba770e8
server.run
# => #<Async::Task:0x0000000000042d80 /Users/samuel/.gem/ruby/ruby-3.4.7/gems/async-2.34.0/lib/async/scheduler.rb:220:in 'IO::Event::Selector::KQueue#resume'>

client = Async::HTTP::Client.new(endpoint)
# => #<Async::HTTP::Client authority="localhost:9292">
client.get("/")
# => #<Async::HTTP::Protocol::HTTP1::Response:0x4a170 status=200>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants