Skip to content

Commit

Permalink
Merge branch 'v1'
Browse files Browse the repository at this point in the history
  • Loading branch information
mirakui committed Nov 23, 2024
2 parents 1391834 + 34ba770 commit 442eee6
Showing 1 changed file with 0 additions and 35 deletions.
35 changes: 0 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,6 @@ We have tested with the following versions of Ruby, ActiveRecord, and databases:
- `2022`

# Examples
## Slow Query Logger
```ruby
class SlowQueryLogger < Arproxy::Base
def initialize(slow_ms)
@slow_ms = slow_ms
end

def execute(sql, name=nil)
result = nil
ms = Benchmark.ms { result = super(sql, name) }
if ms >= @slow_ms
Rails.logger.info "Slow(#{ms.to_i}ms): #{sql}"
end
result
end
end

Arproxy.configure do |config|
config.use SlowQueryLogger, 1000
end
```

## Adding Comments to SQLs
```ruby
Expand All @@ -124,20 +103,6 @@ class CommentAdder < Arproxy::Base
end
```

## Readonly Access
```ruby
class Readonly < Arproxy::Base
def execute(sql, name=nil)
if sql =~ /^(SELECT|SET|SHOW|DESCRIBE)\b/
super sql, name
else
Rails.logger.warn "#{name} (BLOCKED) #{sql}"
nil # return nil to block the query
end
end
end
```

# Use plug-in

```ruby
Expand Down

0 comments on commit 442eee6

Please sign in to comment.