### Installing katsubushi via Go Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This section provides commands to install katsubushi by fetching its source code using `go get` and then building the executable from the project directory using `make`. ```Shell $ go get github.com/kayac/go-katsubushi/v2 $ cd $GOPATH/github.com/kayac/go-katsubushi make ``` -------------------------------- ### Retrieving Multiple IDs via Memcached Protocol Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This example demonstrates using the `GET` command, compatible with the Memcached protocol, to request multiple unique IDs. It shows the expected `VALUE` responses for each requested ID, followed by an `END` marker. ```Protocol GET id1 id2 VALUE id1 0 18 283890203179880448 VALUE id2 0 18 283890203179880449 END ``` -------------------------------- ### Retrieving Server Version via Memcached Protocol Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This example shows the response from the `VERSION` command, which returns the current version string of the katsubushi server, adhering to the Memcached protocol. ```Protocol VERSION 1.1.2 ``` -------------------------------- ### HTTP GET /id Text Response Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet shows the plain text format response when requesting a single ID from the `/id` HTTP endpoint, which is returned when the `Accept` header is not `application/json`. ```Text 1025441401866821632 ``` -------------------------------- ### HTTP GET /id JSON Response Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet displays the JSON format response when requesting a single ID from the `/id` HTTP endpoint, specifically when the `Accept` header is set to `application/json`. ```JSON {"id":"1025441401866821632"} ``` -------------------------------- ### HTTP GET /ids JSON Response Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet illustrates the JSON array format response when requesting multiple IDs from the `/ids?n=(number_of_ids)` HTTP endpoint, specifically when the `Accept` header is set to `application/json`. ```JSON {"ids":["1025442579472195584","1025442579472195585","1025442579472195586"]} ``` -------------------------------- ### HTTP GET /ids Text Response Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet displays the plain text format response (newline-delimited) when requesting multiple IDs from the `/ids?n=(number_of_ids)` HTTP endpoint, returned when the `Accept` header is not `application/json`. ```Text 1025442579472195584 1025442579472195585 1025442579472195586 ``` -------------------------------- ### HTTP GET /stats JSON Response Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet shows the JSON format response for the `/stats` HTTP endpoint, which provides comprehensive server statistics. This API always returns data in JSON format. ```JSON { "pid": 1859630, "uptime": 50, "time": 1664761614, "version": "1.8.0", "curr_connections": 1, "total_connections": 5, "cmd_get": 15, "get_hits": 25, "get_misses": 0 } ``` -------------------------------- ### Running katsubushi Locally Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet shows how to execute the katsubushi binary directly from its compiled location. It demonstrates configuring a worker ID and specifying either a custom port or a Unix domain socket for communication. ```Shell $ cd $GOPATH/github.com/kayac/go-katsubushi/cmd/katsubushi ./katsubushi -worker-id=1 -port=7238 ./katsubushi -worker-id=1 -sock=/path/to/unix-domain.sock ``` -------------------------------- ### Running katsubushi with Docker Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md These commands illustrate how to pull the official katsubushi Docker image and run it, demonstrating configurations for assigning a static worker ID or dynamically assigning one via a Redis server. ```Shell $ docker pull katsubushi/katsubushi $ docker run -p 11212:11212 katsubushi/katsubushi -worker-id 1 $ docker run -p 11212:11212 katsubushi/katsubushi -redis redis://your.redis.host:6379/0 ``` -------------------------------- ### Generating Unique ID via Telnet Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet demonstrates how to connect to a running katsubushi instance using telnet and request a new unique ID. It shows the basic interaction pattern for obtaining an ID through the Memcached-compatible protocol. ```Shell $ telnet localhost 11212 Trying ::1... Connected to localhost. Escape character is '^]'. GET new VALUE new 0 20 8070450532247928832 END ``` -------------------------------- ### Retrieving Server Statistics via Memcached Protocol Source: https://github.com/kayac/go-katsubushi/blob/v2/README.md This snippet illustrates the output of the `STAT` command, which returns various operational statistics of the katsubushi server, such as PID, uptime, version, and connection details, following the Memcached protocol. ```Protocol STAT pid 8018 STAT uptime 17 STAT time 1487754986 STAT version 1.1.2 STAT curr_connections 1 STAT total_connections 2 STAT cmd_get 2 STAT get_hits 3 STAT get_misses 0 ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.