{"id":13839256,"url":"https://github.com/guardian/thrift-serializer","last_synced_at":"2025-04-23T15:51:14.355Z","repository":{"id":45287978,"uuid":"50847620","full_name":"guardian/thrift-serializer","owner":"guardian","description":"Serialize thrift models into bytes","archived":false,"fork":false,"pushed_at":"2025-02-18T18:17:57.000Z","size":210,"stargazers_count":3,"open_issues_count":4,"forks_count":0,"subscribers_count":41,"default_branch":"main","last_synced_at":"2025-04-15T19:17:15.483Z","etag":null,"topics":["misc","production"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/guardian.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2016-02-01T15:13:26.000Z","updated_at":"2025-01-07T12:04:49.000Z","dependencies_parsed_at":"2024-06-27T15:30:47.818Z","dependency_job_id":"d7dcf2e9-ab5e-48d4-8ebd-1f0e7831b03e","html_url":"https://github.com/guardian/thrift-serializer","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fthrift-serializer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fthrift-serializer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fthrift-serializer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/guardian%2Fthrift-serializer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/guardian","download_url":"https://codeload.github.com/guardian/thrift-serializer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250466627,"owners_count":21435403,"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":["misc","production"],"created_at":"2024-08-04T16:00:58.540Z","updated_at":"2025-04-23T15:51:14.296Z","avatar_url":"https://github.com/guardian.png","language":"Scala","funding_links":[],"categories":["Utilities"],"sub_categories":[],"readme":"Thrift Serializer [![Release](https://github.com/guardian/thrift-serializer/actions/workflows/release.yml/badge.svg)](https://github.com/guardian/thrift-serializer/actions/workflows/release.yml)\n========\n_A library for serializing a thrift model into bytes._\n\n[![thrift-serializer Scala version support](https://index.scala-lang.org/guardian/thrift-serializer/thrift-serializer/latest-by-scala-version.svg?platform=jvm)](https://index.scala-lang.org/guardian/thrift-serializer/thrift-serializer)\n\n\n\n### How to use\n\n* Add the library as a depency by adding\n\n```\n\"com.gu\" %% \"thrift-serializer\" % \"2.1.1\"\n```\n\nto your applications libraryDepencies.\n\n* You can then use ThriftSerializer in your application:\n\n```\nimport com.gu.thrift.serializer.ThriftSerializer\n\nobject myObject extends ThriftSerializer {\n\n  def myMethod(thriftObject: MyThriftObject): Unit = {\n    val bytes = serializeToBytes(thriftObject)\n    //Do something with bytes\n  }\n}\n```\n\n* You can use the ThriftDeserializer like this:\n\n```\n\nMyDeserializer.deserialize(buffer).map(myEvent =\u003e {\n  // process the event\n}\n\ndef myMethod(thriftObject: MyThriftObject): Unit = {\n  val bytes = serializeToBytes(thriftObject)\n  //Do something with bytes\n}\n```\n\nIf there is no compression type recorded in the bytes you wish to\ndeserialize or if you don't want these to be included when serializing\na thrift object, you can set the last arguments of the function calls\nto true. They are false by default.\n\n```\nMyDeserializer.deserialize(buffer, true).map(myEvent =\u003e {\n    // process the event\n}\n```\n```\ndef myMethod(thriftObject: MyThriftObject, true): Unit = {\n  val bytes = serializeToBytes(thriftObject)\n  //Do something with bytes\n}\n```\n\n### Node JS\n\n* Install using npm\n\n```\nnpm install --save thrift-serializer\n```\n\nin your application or lambda you can **decode** messages\n\n```\nvar Message = require('your-thrift-model');\nvar serializer = require('thrift-serializer');\n\nserializer.read(Message, bytes, function (err, msg) {\n\tconsole.log(msg);\n});\n```\n\nor **encode** them\n\n```\nvar Message = require('your-thrift-model');\nvar serializer = require('thrift-serializer');\n\nvar message = new Message({\n\tsomeData: ''\n});\n\nserializer.write(message, serializer.Compression.Gzip, function (err, bytes) {\n\t// do something with your bytes, e.g. convert the buffer into a base64 string\n\tconsole.log(bytes.toString('base64'));\n});\n```\n\n## How to make releases (Maven Central):\n\nThis repo uses [`gha-scala-library-release-workflow`](https://github.com/guardian/gha-scala-library-release-workflow)\nto automate publishing releases (both full \u0026 preview releases) - see\n[**Making a Release**](https://github.com/guardian/gha-scala-library-release-workflow/blob/main/docs/making-a-release.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardian%2Fthrift-serializer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fguardian%2Fthrift-serializer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fguardian%2Fthrift-serializer/lists"}