Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/LMAX-Exchange/disruptor-proxy
Byte-code generator to create Disruptor-backed proxies
https://github.com/LMAX-Exchange/disruptor-proxy
Last synced: 2 months ago
JSON representation
Byte-code generator to create Disruptor-backed proxies
- Host: GitHub
- URL: https://github.com/LMAX-Exchange/disruptor-proxy
- Owner: LMAX-Exchange
- License: apache-2.0
- Created: 2013-01-12T07:18:34.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2024-10-16T11:45:44.000Z (3 months ago)
- Last Synced: 2024-11-14T12:53:09.510Z (2 months ago)
- Language: Java
- Size: 1.75 MB
- Stars: 95
- Watchers: 33
- Forks: 36
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-network-stuff - **66**星 - code generator to create Disruptor-backed proxies (<a id="6e80463404d46f0493cf6e84597e4b5c"></a>工具 / <a id="e99ba5f3de02f68412b13ca718a0afb6"></a>Tor&&&Onion&&洋葱)
README
# disruptor-proxy
![Java CI with Gradle](https://github.com/LMAX-Exchange/disruptor-proxy/workflows/Java%20CI%20with%20Gradle/badge.svg)
[![License](https://img.shields.io/github/license/LMAX-Exchange/disruptor-proxy)](https://github.com/LMAX-Exchange/disruptor-proxy/blob/master/LICENCE.txt)The disruptor-proxy is a tool for creating thread-safe proxies to your existing business code.
Utilising the power of the [Disruptor](https://github.com/LMAX-Exchange/disruptor),
disruptor-proxy will provide a high-performance, low-latency multi-threaded interface
to your single-threaded components.This in turn allows users to exploit the
[single-writer principle](http://mechanical-sympathy.blogspot.co.uk/2011/09/single-writer-principle.html)
for maximum straight-line performance.![implementation diagram](https://raw.githubusercontent.com/LMAX-Exchange/disruptor-proxy/master/doc/DisruptorProxy.jpg)
## Maintainer
LMAX Development Team
## Examples
```java
// Basic usage
final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();
final T tImpl = new ConcreteT();
final RingBufferProxyGenerator generator = generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION);
final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);
disruptor.start();
``````java
// Get notified of end-of-batch events
final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();
final T tImpl = new ConcreteT();
final BatchListener batchListener = (BatchListener) tImpl; // implement BatchListener in your componentfinal RingBufferProxyGenerator generator = generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION);
final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);
disruptor.start();
``````java
// Get notified of buffer-overflow events
final RingBufferProxyGeneratorFactory generatorFactory = new RingBufferProxyGeneratorFactory();
final T tImpl = new ConcreteT();
final DropListener dropListener = new MyDropListener(); // handle drop eventsfinal RingBufferProxyGenerator generator =
generatorFactory.newProxy(GeneratorType.BYTECODE_GENERATION,
new ConfigurableValidator(true, true),
dropListener);final T proxy = generator.createRingBufferProxy(T.class, disruptor, OverflowStrategy.DROP, tImpl);
disruptor.start();
```## GeneratorType
* `GeneratorType.JDK_REFLECTION` - uses `java.lang.reflect.Proxy` to generate a dynamic proxy that will add events to the RingBuffer. Use this for minimal dependencies.
* `GeneratorType.BYTECODE_GENERATION` - uses Javassist to generate classes that will add events to the RingBuffer. Use this for maximum performance.## Dependencies
Minimal dependency is the Disruptor JAR.
If you are using byte-code generation for the proxy class (specified by `GeneratorType`), you'll also need the Javassist JAR.