Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed Mar 22, 2024
1 parent fc330ff commit ccb42ef
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 140 deletions.
2 changes: 1 addition & 1 deletion falcon.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
spec.add_dependency "async-http", "~> 0.57"
spec.add_dependency "async-http-cache", "~> 0.4.0"
spec.add_dependency "async-io", "~> 1.22"
spec.add_dependency "async-service", "~> 0.7.0"
spec.add_dependency "async-service", "~> 0.8.0"
spec.add_dependency "bundler"
spec.add_dependency "localhost", "~> 1.1"
spec.add_dependency "openssl", "~> 3.0"
Expand Down
7 changes: 5 additions & 2 deletions lib/falcon/command/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

require_relative '../server'
require_relative '../endpoint'
require_relative '../service/rackup'
require_relative '../service/server'
require_relative '../environment/rackup'

require 'async/container'
require 'async/http/client'
Expand Down Expand Up @@ -51,7 +52,9 @@ def endpoint_options
end

def environment
Async::Service::Environment.new(Falcon::Service::Rackup::Environment).with(
Async::Service::Environment.new(Falcon::Service::Server::Environment).with(
Falcon::Environment::Rackup,

root: Dir.pwd,

verbose: self.parent&.verbose?,
Expand Down
73 changes: 0 additions & 73 deletions lib/falcon/environments/application.rb

This file was deleted.

28 changes: 0 additions & 28 deletions lib/falcon/environments/proxy.rb

This file was deleted.

21 changes: 18 additions & 3 deletions lib/falcon/environments/rack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,26 @@
# Released under the MIT License.
# Copyright, 2019-2023, by Samuel Williams.

require_relative '../service/rackup'
require 'rack/builder'
require_relative '../server'
require_relative '../environments'

module Falcon
module Environments
LEGACY_ENVIRONMENTS[:rack] = Service::Rackup::Environment
module Environment
module Rack
def rackup_path
'config.ru'
end

def rack_app
::Rack::Builder.parse_file(rackup_path)
end

def middleware
::Falcon::Server.middleware(rack_app, verbose: verbose, cache: cache)
end
end

LEGACY_ENVIRONMENTS[:rack] = Rack
end
end
55 changes: 54 additions & 1 deletion lib/falcon/service/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,60 @@ module Falcon
module Service
# Implements an application server using an internal clear-text proxy.
class Application < Server
def initialize(environment)
module Environment
include Server::Environment

# The service class to use for the application.
# @returns [Class]
def service_class
::Falcon::Service::Application
end

# The middleware stack for the application.
# @returns [Protocol::HTTP::Middleware]
def middleware
::Protocol::HTTP::Middleware::HelloWorld
end

# The scheme to use to communicate with the application.
# @returns [String]
def scheme
'https'
end

# The protocol to use to communicate with the application.
#
# Typically one of {Async::HTTP::Protocol::HTTP1} or {Async::HTTP::Protocl::HTTP2}.
#
# @returns [Async::HTTP::Protocol]
def protocol
Async::HTTP::Protocol::HTTP2
end

# The IPC path to use for communication with the application.
# @returns [String]
def ipc_path
::File.expand_path("application.ipc", root)
end

# The endpoint that will be used for communicating with the application server.
# @returns [Async::IO::Endpoint]
def endpoint
::Falcon::ProxyEndpoint.unix(ipc_path,
protocol: protocol,
scheme: scheme,
authority: authority
)
end

# Number of instances to start.
# @returns [Integer | nil]
def count
nil
end
end

def initialize(...)
super

@bound_endpoint = nil
Expand Down
29 changes: 0 additions & 29 deletions lib/falcon/service/rackup.rb

This file was deleted.

2 changes: 1 addition & 1 deletion test/falcon/command/serve.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

it "can listen on specified port" do
configuration = command.configuration
controller = Async::Service::Controller.new(configuration.services.to_a)
controller = configuration.controller

controller.start

Expand Down
2 changes: 1 addition & 1 deletion test/falcon/command/top.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
]

serve = top.command
controller = Async::Service::Controller.new(serve.configuration.services.to_a)
controller = serve.configuration.controller
controller.start

Async do
Expand Down
2 changes: 1 addition & 1 deletion test/falcon/command/virtual.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

def around
configuration = command.configuration
controller = Async::Service::Controller.new(configuration.services.to_a)
controller = configuration.controller

controller.start

Expand Down

0 comments on commit ccb42ef

Please sign in to comment.