-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* multi: Add cache layer This commit adds a cache layer to politeiad and politeiawww. The politeiad git repositories serve as the source of truth for proposal data and a CockroachDB database acts as a cache for proposal data. politeiad has read and write access to the cache. politeiawww has only read access to the cache. The flow of data is as follows: 1. politeiawww receives a command from a user 2. politeiawww creates a politeiad request for the command and sends it 3. politeiad writes the command data to the git repository and updates the cache 4. politeiad returns a response to politeiawww 5. politeiawww reads the cache if needed 6. politeiawww returns a response to the user The cache is automatically rebuilt on cache version change. You can also force the cache to rebuilt by using the flag --buildcache on politeiad startup. The politeiad record and all record metadata has been removed from the politeiawww inventory. The only thing left in the inventory is decred plugin data. The decred plugin data will be added to the cache and removed from the inventory in a future PR. Since this commit touched so much of the code for the `/proposals` endpoints, I began cleaning up `backend.go` and moving the updated `/proposals` enpoint code to `proposals.go`. I had to delete all of the tests that relied on the proposal record in the inventory. I re-wrote most of these tests in `proposals_test.go`. * Add vote data to cache * build plugin cache and fix stuff * cleanup * doco and cleanup * vim playing tricks on me * readme update * doco fixes * votestatus bug fix * fix nits * doco fix
- Loading branch information
1 parent
f2a7885
commit 076c4f8
Showing
46 changed files
with
6,688 additions
and
4,007 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!/usr/bin/env bash | ||
# This script creates the certificates required to run a CockroachDB instance | ||
# locally as a politeiad cache. | ||
|
||
set -ex | ||
|
||
readonly COCKROACHDB_DIR=$1 | ||
|
||
if [ "${COCKROACHDB_DIR}" == "" ]; then | ||
>&2 echo "Error: missing argument CockroachDB directory" | ||
exit | ||
fi | ||
|
||
# Create cockroachdb directories. | ||
mkdir -p "${COCKROACHDB_DIR}/certs" | ||
mkdir -p "${COCKROACHDB_DIR}/data" | ||
|
||
# Create the Certificate Authority certificate and key pair. | ||
cockroach cert create-ca \ | ||
--certs-dir="${COCKROACHDB_DIR}/certs" \ | ||
--ca-key="${COCKROACHDB_DIR}/ca.key" \ | ||
|
||
# Create the node certificate and key. These files, node.crt and node.key, | ||
# will be used to secure communication between nodes. You would generate these | ||
# separately for each node with a unique addresses. | ||
cockroach cert create-node localhost \ | ||
$(hostname) \ | ||
--certs-dir="${COCKROACHDB_DIR}/certs" \ | ||
--ca-key="${COCKROACHDB_DIR}/ca.key" | ||
|
||
# Create the client certificate and key for the root user. These files, | ||
# client.root.crt and client.root.key, will be used to secure communication | ||
# between the built-in SQL shell and the cluster. | ||
cockroach cert create-client root \ | ||
--certs-dir="${COCKROACHDB_DIR}/certs" \ | ||
--ca-key="${COCKROACHDB_DIR}/ca.key" | ||
|
||
# Create the client certificate and key for the politeiad user. | ||
cockroach cert create-client politeiad \ | ||
--certs-dir="${COCKROACHDB_DIR}/certs" \ | ||
--ca-key="${COCKROACHDB_DIR}/ca.key" | ||
|
||
# Create the client certificate and key for politeiawww user. | ||
cockroach cert create-client politeiawww \ | ||
--certs-dir="${COCKROACHDB_DIR}/certs" \ | ||
--ca-key="${COCKROACHDB_DIR}/ca.key" |
Oops, something went wrong.