Buffer Trigger

A buffer with trigger

License

License

The Artistic License 2.0
Categories

Categories

Ant Build Tools
GroupId

GroupId

com.github.phantomthief
ArtifactId

ArtifactId

buffer-trigger
Last Version

Last Version

0.2.19
Release Date

Release Date

Type

Type

jar
Description

Description

Buffer Trigger
A buffer with trigger
Project URL

Project URL

https://github.com/PhantomThief/buffer-trigger
Source Code Management

Source Code Management

https://github.com/PhantomThief/buffer-trigger.git

Download buffer-trigger

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.phantomthief/buffer-trigger/ -->
<dependency>
    <groupId>com.github.phantomthief</groupId>
    <artifactId>buffer-trigger</artifactId>
    <version>0.2.19</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.phantomthief/buffer-trigger/
implementation 'com.github.phantomthief:buffer-trigger:0.2.19'
// https://jarcasting.com/artifacts/com.github.phantomthief/buffer-trigger/
implementation ("com.github.phantomthief:buffer-trigger:0.2.19")
'com.github.phantomthief:buffer-trigger:jar:0.2.19'
<dependency org="com.github.phantomthief" name="buffer-trigger" rev="0.2.19">
  <artifact name="buffer-trigger" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.phantomthief', module='buffer-trigger', version='0.2.19')
)
libraryDependencies += "com.github.phantomthief" % "buffer-trigger" % "0.2.19"
[com.github.phantomthief/buffer-trigger "0.2.19"]

Dependencies

compile (4)

Group / Artifact Type Version
org.slf4j : slf4j-api jar 1.7.21
com.google.guava : guava jar 28.1-jre
com.github.phantomthief : more-lambdas jar 0.1.36
com.google.code.findbugs : jsr305 Optional jar 3.0.2

test (3)

Group / Artifact Type Version
org.junit.jupiter : junit-jupiter-api jar
org.junit.jupiter : junit-jupiter-engine jar
ch.qos.logback : logback-classic jar 1.1.8

Project Modules

There are no modules declared in this project.

buffer-trigger

Build Status Coverage Status Total alerts Language grade: Java Maven Central

A local data buffer with customizable data trigger

  • customize trigger strategy
  • buffer container can be customized
  • jdk1.8 only

Usage

// declare
BufferTrigger<String> buffer = SimpleBufferTrigger.<String, Set<String>> newBuilder()
        .triggerStrategy(new MultiIntervalTriggerStrategy()
            .on(10, SECONDS, 1)
            .on(5, SECONDS, 10)
            .on(1, SECONDS, 100)
        )
        .consumer(this::out)
        .setContainer(ConcurrentSkipListSet::new, Set::add) // default is Collections.newSetFromMap(new ConcurrentHashMap<>())
        .build();
        
// enqueue
buffer.enqueue("i'm ok");

// consumer declare
private void out(Collection<String> set) {
	set.forEach(System.out::println);
}

// batch consumer blocking queue
BufferTrigger<String> buffer = BatchConsumeBlockingQueueTrigger.<String> newBuilder()
                .batchSize(3)
                .setConsumerEx(this::out)
                .bufferSize(5)
                .linger(ofSeconds(2))
                .build();
    

Special Thanks

perlmonk with his great team gives me a huge help. (https://github.com/aloha-app)

Versions

Version
0.2.19
0.2.18
0.2.17
0.2.15
0.2.14
0.2.13
0.2.12
0.2.11
0.2.10
0.2.9
0.2.8
0.2.6
0.2.5
0.2.4
0.2.3
0.2.2
0.2.1
0.2.0
0.1.0