{"id":16719210,"url":"https://github.com/reiddraper/sumo","last_synced_at":"2025-03-17T01:31:21.191Z","repository":{"id":2047348,"uuid":"2984854","full_name":"reiddraper/sumo","owner":"reiddraper","description":"Clojure driver for Riak","archived":false,"fork":false,"pushed_at":"2012-12-18T21:46:10.000Z","size":187,"stargazers_count":51,"open_issues_count":3,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-11T11:51:43.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"LloydGhettoWolf/Python-Renderer","license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/reiddraper.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":"2011-12-15T02:13:01.000Z","updated_at":"2024-06-14T00:56:17.000Z","dependencies_parsed_at":"2022-08-20T17:20:17.462Z","dependency_job_id":null,"html_url":"https://github.com/reiddraper/sumo","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiddraper%2Fsumo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiddraper%2Fsumo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiddraper%2Fsumo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reiddraper%2Fsumo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reiddraper","download_url":"https://codeload.github.com/reiddraper/sumo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835959,"owners_count":20355613,"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-10-12T21:40:57.152Z","updated_at":"2025-03-17T01:31:20.813Z","avatar_url":"https://github.com/reiddraper.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sumo\n\n## Build status\n\n[![Build Status](https://secure.travis-ci.org/reiddraper/sumo.png)](http://travis-ci.org/reiddraper/sumo)\n\n## Dependencies\n\n```\nlein deps\n```\n\nTo use sumo with another project, add `[sumo \"0.2.0\"]` to your `project.clj`.\n\n## Usage\n```clojure\n(require '[sumo.client :as sumo]\n         '[clojure.pprint :as pp])\n\n;; connect with the protocol buffers\n;; client\n(def client (sumo/connect-pb))\n\n;; three examples of how to connect\n;; with HTTP\n(sumo/connect-http)\n(sumo/connect-http \"http://prod0.example.com:8098/riak\")\n(sumo/connect-http \"127.0.0.1\" 8098)\n;; the last param is the HTTP path that all riak\n;; requests start with. You might have your proxy\n;; change this, for example.\n(sumo/connect-http \"127.0.0.1\" 8098 \"riak\")\n\n(sumo/ping client)\n;; =\u003e true\n\n(sumo/put client \"bucket\" \"key\" {:value \"hello, sumo!\"})\n;; =\u003e nil\n\n;; sumo will default to \"application/json\" content-type and serialization\n;; you can override this by setting it in the object hash-map\n(sumo/put client \"bucket\" \"key\" {:content-type \"text/plain\"\n                                 :value \"hello, sumo!\"})\n;; =\u003e nil\n\n\n;; returns a lazy-seq of hash-maps\n(pp/pprint (sumo/get client \"bucket\" \"key\"))\n;; =\u003e ({:value \"hello, sumo!\",\n;;      :metadata {},\n;;      :last-modified #\u003cDate Sun Dec 18 20:40:03 CST 2011\u003e,\n;;      :vtag \"6YWpgJW8WpnKlNTOeOxKZf\",\n;;      :content-type \"application/json\",\n;;      :vector-clock\n;;      #\u003cBasicVClock com.basho.riak.client.cap.BasicVClock@50aec4\u003e})\n\n;; you can also pass an options hash-map into requests\n;; for example, to use an R value of 2 and only return the object metadata\n(sumo/get client \"bucket\" \"key\" {:r 2 :head true}))\n\n;; or to use a W value of 3 and return a lazy-seq of hash-maps just like sumo/get\n(sumo/put client \"bucket\" \"key\" {:value \"hey there\"}\n                                {:w 3 :return-body true})\n\n;; you can store secondary indexes by adding an :indexes hash-map containing\n;; keywords as keys and sets as values to your object\n(sumo/put client \"bucket\" \"key\" {:value {:name \"John\" :email \"john@example.com\"}\n                                 :indexes {:email #{\"john@example.com\"}})\n\n;; querying secondary indexes is supported as well\n(sumo/index-query client \"bucket\" :email \"john@example.com\")\n\n; search for a range of strings\n(sumo/index-query client \"bucket\" :email [\"i\" \"k\"])\n\n; or of integers\n(sumo/index-query client \"bucket\" :age [21 80])\n\n;; Here is an example of sumo's map-reduce support,\n;; it follows the data from this example from the\n;; Riak wiki, http://wiki.basho.com/MapReduce.html#HTTP-Example\n\n(require '[sumo.mr-helpers :as mr-helpers])\n\n(def query {\"inputs\" [[\"alice\" \"p1\"] [\"alice\" \"p2\"] [\"alice\" \"p5\"]]\n            \"query\" [(mr-helpers/map-js \"function(v) {return [1]}\")\n                     (mr-helpers/reduce-erlang \"riak_kv_mapreduce\" \"reduce_sum\")]})\n\n;; the query parameter to the map-reduce\n;; call is a data structure that will be\n;; json-encoded and used for the query.\n;; Read through http://wiki.basho.com/MapReduce.html\n;; for more examples of how to use map-reduce with Riak\n(sumo/map-reduce client query)\n```\n\n## Roadmap\n\nsumo currently supports key/value access, secondary indexes\nand map-reduce. The following is a TODO list of sorts\nalong with some ideas for a higher level interface.\n\n### TODO\n\n* multi-client connections\n* http connections (sumo is currently just protocol buffers)\n* links\n* search\n\n### Higher-level interface ideas\n\nThese are just some ideas we've been playing\naround with for how the high-level API might look:\n\nApply a series of forms to whatever\nvalue is currently stored at `bucket`, `key`:\n\n```clojure\n;; Apply a form to the\n;; current value at `key`,\n;; and resave. Similar to Mutations\n;; in the Java client\n(send-riak \"bucket\" \"key\"\n  ;; your form will be called\n  ;; threading in the obj\n  ;; as the second value,\n  ;; much like (-\u003e obj (..) (..))\n  (assoc-in [:value] inc))\n```\n\nThe next idea is an ODM of sorts that supports\nautomatic conflict-resolution of your domain objects\nbut letting you construct them from [knockbox](http://github.com/reiddraper/knockbox)\ndata types.\n\n```clojure\n(defbox Account\n  ;; the second item in the\n  ;; list is a type or protocol\n  ;; to restrict the value to\n  (:name       LWWRegister :required true)\n  (:address    LWWRegister :required true)\n  ;; specify a default value for this field,\n  ;; in this case, the result of calling the\n  ;; function `lww-set`\n  (:followers  ObservedRemoveSet :default (lww-set)))\n\n(def person (Account.))\n\n(-\u003e person\n  ;; add :bar to the followers list\n  (update-in [:followers] conj :bar)\n  ;; set the name\n  (assoc-in  [:name]      \"Reid\")\n  ;; set the address\n  (assoc-in  [:address]   \"27 Lexington Ave\"))\n```\n\n## License\nCopyright (c) 2011 Basho Technologies, Inc.  All Rights Reserved.\n\nSumo is released under the Apache 2 License. See LICENSE file for more information.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiddraper%2Fsumo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freiddraper%2Fsumo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freiddraper%2Fsumo/lists"}