akka-stream-session-window


License

License

Categories

Categories

Akka Container Microservices Reactive libraries
GroupId

GroupId

io.github.efekahraman
ArtifactId

ArtifactId

akka-stream-session-window_2.12
Last Version

Last Version

0.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

akka-stream-session-window
akka-stream-session-window
Project URL

Project URL

http://ekahraman.me
Project Organization

Project Organization

io.github.efekahraman
Source Code Management

Source Code Management

https://github.com/efekahraman/akka-streams-session-window

Download akka-stream-session-window_2.12

How to add to project

<!-- https://jarcasting.com/artifacts/io.github.efekahraman/akka-stream-session-window_2.12/ -->
<dependency>
    <groupId>io.github.efekahraman</groupId>
    <artifactId>akka-stream-session-window_2.12</artifactId>
    <version>0.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/io.github.efekahraman/akka-stream-session-window_2.12/
implementation 'io.github.efekahraman:akka-stream-session-window_2.12:0.1.0'
// https://jarcasting.com/artifacts/io.github.efekahraman/akka-stream-session-window_2.12/
implementation ("io.github.efekahraman:akka-stream-session-window_2.12:0.1.0")
'io.github.efekahraman:akka-stream-session-window_2.12:jar:0.1.0'
<dependency org="io.github.efekahraman" name="akka-stream-session-window_2.12" rev="0.1.0">
  <artifact name="akka-stream-session-window_2.12" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.github.efekahraman', module='akka-stream-session-window_2.12', version='0.1.0')
)
libraryDependencies += "io.github.efekahraman" % "akka-stream-session-window_2.12" % "0.1.0"
[io.github.efekahraman/akka-stream-session-window_2.12 "0.1.0"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.12.7

provided (1)

Group / Artifact Type Version
com.typesafe.akka : akka-stream_2.12 jar 2.5.16

test (2)

Group / Artifact Type Version
com.typesafe.akka : akka-stream-testkit_2.12 jar 2.5.16
org.scalatest : scalatest_2.12 jar 3.0.5

Project Modules

There are no modules declared in this project.

Build Status

Session Window extension for Akka Streams

This library provides session windowing for the Akka Streams.

Session windowing helps to identify periods of activity. This library uses a static idle period and favors the processing time for events to distinguish the periods. More information can be found in the related blog post.

Defines a FlowShape with same input and output types as GraphStage[FlowShape[T, T]]. Requires 3 parameters:

  • gap: Idle time to determine particular activity as a session.
  • maxSize: Max elements to hold in session buffer.
  • overflowStrategy: Strategy to define what happens when new elements arrive and buffer is full. Can be one of:
    • DropOldest: Drops the oldest message in the buffer and adds the new one.
    • DropNewest: Drops the new message.
    • FailStage: Fails the stream with SessionOverflowException.

Versions

Current version is built with Akka Streams 2.5.16.

Cross compiled with Scala 2.12 and 2.11.

Dependency

libraryDependencies += "io.github.efekahraman" %% "akka-stream-session-window" % "0.1.0"

Examples

Below snippets show how to create a session window.

Scala

import akka.stream._
import akka.stream.scaladsl._

import io.github.efekahraman.akka.stream.DropOldest
import io.github.efekahraman.akka.stream.scaladsl.SessionWindow

import scala.concurrent.duration._

val source: Source[String, NotUsed] = ???
val sessionWindow: GraphStage[FlowShape[String, String]] = SessionWindow(10 second, 5, DropOldest)

val windowedSource = source.via(sessionWindow)
// ...

Java

import akka.stream.*;
import akka.stream.javadsl.*;

import io.github.efekahraman.akka.stream.javadsl.*;

import java.time.Duration;

final Source<String, NotUsed> source = // ...
final GraphStage<FlowShape<String, String>> sessionWindow = SessionWindow.apply(Duration.ofSeconds(10), 5, SessionOverflowStrategy.dropOldest());

final Source<ReadResult, NotUsed> windowedSource = amqpSource.via(window);
//...

License

Code is available under the Apache 2 license, available at https://opensource.org/licenses/Apache-2.0.

Versions

Version
0.1.0