{"id":22725362,"url":"https://github.com/ovotech/clj-gcp","last_synced_at":"2025-04-13T20:29:41.063Z","repository":{"id":54533149,"uuid":"148327232","full_name":"ovotech/clj-gcp","owner":"ovotech","description":"Clojure utilities for the Google Cloud Platform.","archived":false,"fork":false,"pushed_at":"2023-03-22T11:33:54.000Z","size":77,"stargazers_count":22,"open_issues_count":8,"forks_count":6,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-27T10:51:19.916Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"epl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ovotech.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}},"created_at":"2018-09-11T14:06:28.000Z","updated_at":"2023-09-02T13:29:42.000Z","dependencies_parsed_at":"2022-08-13T19:00:18.292Z","dependency_job_id":null,"html_url":"https://github.com/ovotech/clj-gcp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fclj-gcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fclj-gcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fclj-gcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ovotech%2Fclj-gcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ovotech","download_url":"https://codeload.github.com/ovotech/clj-gcp/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610031,"owners_count":21132919,"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":[],"created_at":"2024-12-10T16:09:26.584Z","updated_at":"2025-04-13T20:29:41.034Z","avatar_url":"https://github.com/ovotech.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# clj-gcp [![CircleCI](https://circleci.com/gh/ovotech/clj-gcp/tree/master.svg?style=svg)](https://circleci.com/gh/ovotech/clj-gcp/tree/master)\n\nClojure utilities for the Google Cloud Platform.\n\n\n## Usage\n\n[![Clojars Project](https://img.shields.io/clojars/v/ovotech/clj-gcp.svg)](https://clojars.org/ovotech/clj-gcp)\n\n\n### Pub-Sub\nMainly used through integrant:\n\n```clojure\n;; ig-config.edn\n:clj-gcp.pub-sub.core/subscriber\n{:metrics-registry     #ig/ref :metrics/registry ;; a iapetos metric registry\n :handler              #ig/ref :pubsub/handler ;; a fn, described below\n :project-id                   \"my-gcp-project\"\n :topic-id                     \"industry-data-lake-file-notifications\"\n :pull-max-messages            10\n :subscription-id              \"LOCAL_DEV.bucket-notifications.my-service\"}\n```\n\nThe function `:handler` takes **a seq of maps that contain**:\n```clojure\n{,,, pub-sub message fields (always deserialized as JSON) ,,,\n :pubsub/attributes {:eventType \"OBJECT_FINALIZE\"}\n :pubsub/ack-id     \"0000000ACK\"}\n```\n... and should return **a seq of maps that contain at least**:\n```clojure\n;; these will be acked:\n{:pubsub/ack-id     \"0000000ACK\"\n :ok? true}\n{:pubsub/ack-id     \"0000000ACK\"\n :ok? false\n :retry? false}\n\n;; this will be nacked:\n{:pubsub/ack-id     \"0000000ACK\"\n :ok? false\n :retry? true}\n```\n\n\n#### Healthcheck\n\nThere's also a healthcheck integrant key available:\n\n```clojure\n;; ig-config.edn\n:clj-gcp.pub-sub.core/subscriber.healthcheck\n{:project-id     \"my-gcp-project\"\n :subscription-id \"LOCAL_DEV.bucket-notifications.my-service\"}\n```\n\n### Storage\n\n```clojure\n(let [sut                 (sut/-\u003egcs-storage-client)\n      blob-name           (format \"TEST_BLOBS/BLOB-%s.txt\" (m/random-uuid))\n      exp-contentEncoding \"utf-8\"\n      exp-content         \"hello!\"\n      exp-metadata        {\"hi\" \"foo\"}\n      exp-contentType     \"text/plain\"]\n\n  ;; This is how you write a blob:\n  (with-open [out (Channels/newWriter\n                   (sut/blob-writer sut\n                                    bucket-name\n                                    blob-name\n                                    {:metadata        exp-metadata,\n                                     :contentType     exp-contentType,\n                                     :contentEncoding exp-contentEncoding})\n                   exp-contentEncoding)]\n    (.write out exp-content))\n\n  ;; ... and this is how you get it back\n  (let [{:keys [inputStream md5Hash contentType source\n                contentEncoding metadata],\n         :as   got}\n        (sut/get-blob sut bucket-name blob-name)]\n    (tu/is-valid ::sut/blob got)\n    (is (= (str \"gs://\" bucket-name \"/\" blob-name) source))\n    (is (= exp-contentType contentType))\n    (is (= exp-contentEncoding contentEncoding))\n    (is (= exp-metadata metadata))\n    (is (= exp-content (slurp inputStream)))))\n```\n\nCan also be used as an Integrant component:\n\n```\n;; ig-config.edn\n:clj-gcp.storage/client             nil\n:clj-gcp.storage/client.healthcheck nil\n```\n\n#### Testing implementation\n\nA test implementation based on the file system is available:\n\n```clojure\n(sut/-\u003efile-system-storage-client base-path)\n```\n\n\n## Running Tests\n\n```bash\nGCP_PROJECT_ID=my-gcp-project lein test :integration\n```\n\n\n## License\n\nCopyright © 2018 OVO Energy Ltd.\n\nDistributed under the Eclipse Public License either version 1.0 or (at\nyour option) any later version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovotech%2Fclj-gcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fovotech%2Fclj-gcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fovotech%2Fclj-gcp/lists"}