Bulk 0.7.0

Bulk 0.7.0

LangLanguage SwiftSwift
License MIT
ReleasedLast Release Mar 2020
SPMSupports SPM

Maintained by muukii, muukii.

Bulk 0.7.0

Bulk / BulkLogger

Version platforms

Bulk is a library for buffering the objects. Pipeline(Sink) receives the object and emits the object bulked.

What is for?

To pack a lot of elements would be helpful in several cases. For example, sending the analytics events for your products with in house API.

  • collect the many events
  • pack it into one
  • send these events as a set of events.

Bulk module

Make a sink

We call the pipeline that receives the object as Sink.

Sink receives the objects and emits the bulked object to multiple targets.

  1. Select the buffer.

To create a bulk, we can choose several types of the buffer.
Currently, Bulk provides 2 types below.

  • MemoryBuffer
  • FileBuffer

In this tutorial, we select MemoryBuffer.

  1. Create the target

Target receives the bulked object from Sink.

Bulk does not privides default implemented Target.
For now, you need to create it.

public protocol TargetType {

  associatedtype Element

  func write(items: [Element])
struct MyTarget<Element>: TargetType {

  func write(items: [Element]) {

And finally, create BulkSink object.

let sink = BulkSink<String>(
  buffer: MemoryBuffer.init(size: 10).asAny(),
  targets: [

Send the objects


sink sends the bulked object when Buffer receives the objects up to the specified size (10 elements in the example).

BulkLogger module

The Logger as a library on top of Bulk.

BulkLogger provies Logger object that wraps Sink inside.

let logger = Logger(context: "", sinks: [
    buffer: MemoryBuffer.init(size: 10).asAny(),
    targets: [

        transform: LogBasicFormatter().format,
        targets: [

      OSLogTarget(subsystem: "BulkDemo", category: "Demo").asAny()

Logger object send the log data to 2 targets (LogConsoleTarget and OSLogTarget)



Bulk Framework is released under the MIT License.