Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

semian-postgres

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

semian-postgres

  • 0.1.8
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

semian-postgres

CI Workflow Gem Version

This library provides a Postgres adapter for Semian by wrapping the pg gem Semian is a resiliency toolkit for Ruby applications that provides a way to protect your application from external failures by limiting the number of resources that can be used at a time. You can read more about Semian here).

Usage

Add the gem to your Gemfile and require it in your application.

gem 'semian-postgres', require: %w(semian semian/pg)

Configuration

The adapter is configured by a callback function, which would be ideally defined in some sort of initialization file. For Rails applications these would usually live in the config/initializers/ directory.

Minimal example

The following example configures an adapter to open the circuit after three unsuccessful connection attempts and close it after each successful attempt.

Bulkheading is disabled, because this is not supported with servers that have a thread-oriented model, such as Puma

require "semian"
require "semian/pg"

SEMIAN_PARAMETERS = {
  circuit_breaker: true,
  success_threshold: 1,
  error_threshold: 3,
  error_timeout: 3,
  bulkhead: false,
}

Semian::PG.semian_configuration = proc do |host, port|
  if host == "localhost" && port == 5432
    return SEMIAN_PARAMETERS
  end
end

conn = PG.connect(host: "example.com", port: 5432)
conn.exec("SELECT 1")

Development

Semian, and by extension semian-postgres, currently depends on Linux for Bulkheading.

The development environment is based on docker-compose, spinning up containers for Postgres and Toxiproxy. Additionally a dev container is spun up. The Gemfile contains ruby-debug-ide to support remote debugging from the IDE.

A typical development workflow would be to run the tests in the dev container

docker compose up -d
docker compose exec dev bin/setup
docker compose exec dev rake rubocop spec

Contributing

Bug reports and pull requests are welcome on GitHub.

Thanks to everyone that has already contributed

Pictures of the folks who have contributed to the project

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 30 Nov 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc