
Security News
Astral Launches pyx: A Python-Native Package Registry
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
An EM-Synchrony handler for Ruby AWS-SDK-Ruby
EM::AWS is available through Rubygems and can be installed via:
$ gem install em_aws
Setup AWS-SDK-Ruby as you would normally.
Assuming you've already setup async-rails, add em_aws to your gemfile:
gem 'em_aws'
Then run:
bundle install
Add the following to your aws.rb initializer:
require 'em-aws'
AWS.config( :http_handler => EM::AWS::HttpHandler.new )
You are done.
All requests to AWS will use EM-Synchrony's implementation of em-http-request for non-block HTTP requests and fiber management. See EM-HTTP-Request for all client options
We use EM-HotTub to manage connection pooling. To enable connection pooling set the :pool_size to anything greater than 1, default is 5. By default :inactivity_timeout is set to 0 which will leave the connection open for as long as the AWS allows. Connections are created lazy, so pools grows to meet concurrency. If we need to limit our total number of connections we can set :max_size. HotTub will reap connections down to :pool_size when load dies.
require 'em-aws'
AWS.config(
:http_handler => EM::AWS::HttpHandler.new({
:pool_size => 20, # default is 5, setting to 1 disables pool
)
Streaming from disk,You can pass an IO object in the :data option instead but the object must respond to :path. We cannot stream from memory at this time.
EM.synchrony do
s3 = AWS::S3.new
s3.buckets['bucket_name'].objects["foo.txt"].write(:file => "path_to_file")
EM.stop
end
# Stream from AWS
EM.synchrony do
s3 = AWS::S3.new
s3.buckets['bucket_name'].objects["foo.txt"].read do |chunk|
puts chunk
end
EM.stop
end
Requests can be set to perform asynchronously, returning nil initially and performing the actions in the background. If the request option :async are set to true, only that request will be handled asynchronously. If the client option :async is set to true, all requests will be handled asynchronously.
EM.synchrony do
s3 = AWS::S3.new
s3.buckets['bucket-name'].objects["foo"].write('test', :async => true) # => nil
EM::Synchrony.sleep(2) # Let the pending fibers run
s3.buckets['bucket-name'].objects["foo"].read # => # 'test'
s3.buckets['bucket-name'].objects["foo"].delete(:async => true) # => nil
EM::Synchrony.sleep(2) # Let the pending fibers run
EM.stop
end
Code based on HTTP Handers in AWS-SDK-Ruby
FAQs
Unknown package
We found that em_aws demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.
Security News
The latest Opengrep releases add Apex scanning, precision rule tuning, and performance gains for open source static code analysis.