{"id":13635252,"url":"https://github.com/FluidGroup/Bulk","last_synced_at":"2025-04-19T03:34:45.797Z","repository":{"id":20549813,"uuid":"90060888","full_name":"FluidGroup/Bulk","owner":"FluidGroup","description":"👨‍💻 Bulk is a library for buffering the objects. Pipeline(Sink) receives the object and emits the object bulked.","archived":false,"fork":false,"pushed_at":"2024-10-21T05:37:51.000Z","size":700,"stargazers_count":60,"open_issues_count":0,"forks_count":3,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-22T14:31:06.223Z","etag":null,"topics":["logger","logging","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/FluidGroup.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-05-02T17:41:43.000Z","updated_at":"2024-10-21T05:32:22.000Z","dependencies_parsed_at":"2022-09-16T20:01:08.757Z","dependency_job_id":null,"html_url":"https://github.com/FluidGroup/Bulk","commit_stats":{"total_commits":106,"total_committers":2,"mean_commits":53.0,"dds":0.3679245283018868,"last_synced_commit":"470ae39d0d3da978c80335fdd465e293e14650c4"},"previous_names":["muukii/bulk"],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2FBulk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2FBulk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2FBulk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/FluidGroup%2FBulk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/FluidGroup","download_url":"https://codeload.github.com/FluidGroup/Bulk/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223790258,"owners_count":17203353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["logger","logging","swift"],"created_at":"2024-08-02T00:00:43.020Z","updated_at":"2024-11-09T05:30:27.565Z","avatar_url":"https://github.com/FluidGroup.png","language":"Swift","funding_links":[],"categories":["Logger"],"sub_categories":[],"readme":"# Bulk / BulkLogger\n\n[![Version](https://img.shields.io/cocoapods/v/Bulk.svg?style=flat)](http://cocoapods.org/pods/Bulk)\n![platforms](https://img.shields.io/badge/platforms-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20Linux-333333.svg)\n\nBulk is a library for buffering the objects.\nPipeline(Sink) receives the object and emits the object bulked.\n\n## What is for?\n\nTo pack a lot of elements would be helpful in several cases.\nFor example, sending the analytics events for your products with in house API.\n\n- collect the many events\n- pack it into one\n- send these events as a set of events.\n\n## Bulk module\n\n### Make a sink\n\nWe call the pipeline that receives the object as `Sink`.\n\n`Sink` receives the objects and emits the bulked object to multiple targets.\n\n1. Select the buffer.\n\nTo create a bulk, we can choose several types of the buffer.\u003cbr\u003e\nCurrently, Bulk provides 2 types below.\n\n- MemoryBuffer\n- FileBuffer\n\nIn this tutorial, we select MemoryBuffer.\n\n2. Create the target\n\nTarget receives the bulked object from Sink.\n\nBulk does not privides default implemented Target.\u003cbr\u003e\nFor now, you need to create it.\n\n```swift\npublic protocol TargetType {\n\n  associatedtype Element\n\n  func write(items: [Element])\n}\n```\n\n```swift\nstruct MyTarget\u003cElement\u003e: TargetType {\n\n  func write(items: [Element]) {\n    print(items)\n  }\n}\n```\n\nAnd finally, create BulkSink object.\n\n```swift\nlet sink = BulkSink\u003cString\u003e(\n  buffer: MemoryBuffer.init(size: 10).asAny(),\n  targets: [\n    MyTarget\u003cString\u003e().asAny()\n  ]\n)\n```\n\nSend the objects\n\n```swift\nsink.send(\"A\")\nsink.send(\"B\")\nsink.send(\"C\")\n```\n\n`sink` sends the bulked object when Buffer receives the objects up to the specified size (10 elements in the example).\n\n## BulkLogger module\n\nThe Logger as a library on top of Bulk.\n\nBulkLogger provies `Logger` object that wraps `Sink` inside.\n\n```swift\nlet logger = Logger(context: \"\", sinks: [\n  BulkSink\u003cLogData\u003e(\n    buffer: MemoryBuffer.init(size: 10).asAny(),\n    targets: [\n\n      TargetUmbrella.init(\n        transform: LogBasicFormatter().format,\n        targets: [\n          LogConsoleTarget.init().asAny()\n        ]\n      ).asAny(),\n\n      OSLogTarget(subsystem: \"BulkDemo\", category: \"Demo\").asAny()\n    ]\n  )\n    .asAny()\n])\n```\n\nLogger object send the log data to 2 targets (LogConsoleTarget and OSLogTarget)\n\n```swift\nlogger.verbose(\"Hello\")\n```\n\n# LICENSE\n\nBulk Framework is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFluidGroup%2FBulk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFluidGroup%2FBulk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFluidGroup%2FBulk/lists"}