{"id":37163559,"url":"https://github.com/onsdigital/dp-reporter-client","last_synced_at":"2026-01-14T19:27:10.533Z","repository":{"id":48308007,"uuid":"105867736","full_name":"ONSdigital/dp-reporter-client","owner":"ONSdigital","description":null,"archived":false,"fork":false,"pushed_at":"2024-11-22T09:17:26.000Z","size":290,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":25,"default_branch":"main","last_synced_at":"2025-06-16T13:14:39.595Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","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/ONSdigital.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","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}},"created_at":"2017-10-05T08:45:01.000Z","updated_at":"2024-11-22T09:17:29.000Z","dependencies_parsed_at":"2024-06-21T00:24:41.896Z","dependency_job_id":"9a31c5e7-2081-431c-ba7d-091afb30bae8","html_url":"https://github.com/ONSdigital/dp-reporter-client","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/ONSdigital/dp-reporter-client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ONSdigital%2Fdp-reporter-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ONSdigital%2Fdp-reporter-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ONSdigital%2Fdp-reporter-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ONSdigital%2Fdp-reporter-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ONSdigital","download_url":"https://codeload.github.com/ONSdigital/dp-reporter-client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ONSdigital%2Fdp-reporter-client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28432604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-14T18:57:19.464Z","status":"ssl_error","status_checked_at":"2026-01-14T18:52:48.501Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":[],"created_at":"2026-01-14T19:27:09.698Z","updated_at":"2026-01-14T19:27:10.507Z","avatar_url":"https://github.com/ONSdigital.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"dp-reporter-client\n================\n\nA client for sending report events to the dp-import-reporter\n\n### Getting started\n##### Reporting an import error\nReport an import pipeline error via the `ImportErrorReporter`. To create a new ImportErrorReporter you need to provide a\n KafkaProducer [see dp-kafka kafka.Producer](https://github.com/ONSdigital/dp-kafka/blob/master/producer.go) and service\n  name. The producer should already be configured to talk to the desired instance of the reporter and the service name \n  should be the name of your service - as this is where the error event has occurred. __NOTE:__ It is the responsibility\n   of the caller to gracefully close the KafkaProducer and handle any error it returns.\n```go\n\tvar p KafkaProducer\n\terrReporter, err := reporter.NewImportErrorReporter(p, \"MyService\")\n\tif err != nil {\n\t\t//...handle error\n\t}\n``` \n##### Report an error event\nTo report an error event you __MUST__ provide an __instanceID__ and an __error context__ the reporter requires \nboth parameters in order to update the instance. If neither are provided the client will not attempt to report the \nevent and will return an error. Additionally you can provide the error causing the event the and any additional \nlogging data.\n```go\n    if err := errReporter.Notfiy(\"instance-123\", \"unexpected http response status\", err); err != nil {\n        //...handle error\n    }\n```\n#### Testing\nThe `reporter.ErrorReporter` interface can be used in place of the `ImportErrorReporter` struct in cases where it is a\nmember of another struct or function parameter. Accepting this interface instead of the concrete struct allows the \nreporter to be easily tested. For example given:\n```go\n    type Foo struct {\n        errReporter reporter.ErrorReporter\n    }\n    \n    func (f Foo) Bar(id string, context string, cause error) error {\n        return f.errReporter.Notify(id, context, cause)\n    }\n``` \n\nTesting the above:\n\n```go\n\tConvey(\"Test Foo.Bar\", t, func() {\n\t\t// The expected parameters to the Notify func\n\t\texpectedParams := reportertest.NotfiyParams{\n\t\t\tID:         \"666\",\n\t\t\tErrContext: \"666\",\n\t\t\tErr:        errors.New(\"bar\"),\n\t\t}\n \n\t\t// The error to return when Notify is called.\n\t\texpectedErr := errors.New(\"expected error\")\n  \n\t\t// Create the mock \u0026 configure to return the expected error\n\t\treporterMock := reportertest.NewImportErrorReporterMock(expectedErr)\n\n\t\tfoo := Foo{\n\t\t\terrReporter: reporterMock,\n\t\t}\n\t\t\n\t\t// run the test\n\t\terr := foo.Bar(\"666\", \"666\", errors.New(\"bar\"))\n \n\t\t// Check the return val, number of invocations and the parameters supplied to Notify\n\t\tSo(err, ShouldResemble, expectedErr)\n\t\tSo(len(reporterMock.NotifyCalls()), ShouldEqual, 1)\n\t\tSo(reporterMock.NotifyCalls()[0], ShouldResemble, expectedParams)\n\t})\n```\nThe kafka producer mock `kafka.MessageProducer` from dp-kafka package is used for testing, creating the channels if the test requires it:\n```\n\tpChannels := kafka.CreateProducerChannels()\n\tp := kafkatest.NewMessageProducerWithChannels(p)\n\n    output := make(chan []byte, 1)\n    p := reportertest.NewKafkaProducerMock(output)\n\tgo func() {\n\t\t...\n\t}()\n    ...\n\tavroBytes := \u003c-kafkaProducer.Channels().Output\n```\n### Contributing\n\nSee [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n### License\n\nCopyright © 2016-2021, Office for National Statistics (https://www.ons.gov.uk)\n\nReleased under MIT license, see [LICENSE](LICENSE.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonsdigital%2Fdp-reporter-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fonsdigital%2Fdp-reporter-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fonsdigital%2Fdp-reporter-client/lists"}