-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
3,314 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
### Expected behaviour | ||
|
||
Describe the issue; with what you expect to happen | ||
|
||
### Actual behaviour | ||
|
||
Describe the issue; is currently happening | ||
|
||
### Steps to reproduce the issue | ||
|
||
Provide a detailed step by step method on how to reliably recreate the issue | ||
|
||
### Environment information | ||
|
||
Provide information relevant to the issue such as | ||
* Operating system | ||
* Browser | ||
* Relevant environment variables | ||
* Feature flags if known |
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,11 @@ | ||
### What | ||
|
||
Describe what you have changed and why. | ||
|
||
### How to review | ||
|
||
Describe the steps required to test the changes. | ||
|
||
### Who can review | ||
|
||
Describe who worked on the changes, so that other people can review. |
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,12 @@ | ||
/build | ||
|
||
# Mac | ||
.DS_Store | ||
|
||
#VSCode | ||
.vscode | ||
|
||
# Intellij | ||
.idea/ | ||
*.iml | ||
*.iws |
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,97 @@ | ||
# This file was inspired by the golangci-lint one: | ||
# https://github.com/golangci/golangci-lint/blob/master/.golangci.yml | ||
run: | ||
# default concurrency is a available CPU number | ||
concurrency: 4 | ||
|
||
# timeout for analysis, e.g. 30s, 5m, default is 1m | ||
timeout: 5m | ||
linters-settings: | ||
govet: | ||
check-shadowing: true | ||
golint: | ||
min-confidence: 0 | ||
gocyclo: | ||
min-complexity: 15 | ||
maligned: | ||
suggest-new: true | ||
dupl: | ||
threshold: 100 | ||
goconst: | ||
min-len: 2 | ||
min-occurrences: 2 | ||
misspell: | ||
locale: UK | ||
lll: | ||
line-length: 140 | ||
gofmt: | ||
simplify: false | ||
gocritic: | ||
enabled-tags: | ||
- diagnostic | ||
- experimental | ||
- opinionated | ||
- performance | ||
- style | ||
disabled-checks: | ||
- wrapperFunc | ||
- dupImport # https://github.com/go-critic/go-critic/issues/845 | ||
- ifElseChain | ||
- octalLiteral | ||
- hugeParam | ||
funlen: | ||
# lines: 100 | ||
# statements: 100 | ||
|
||
linters: | ||
# please, do not use `enable-all`: it's deprecated and will be removed soon. | ||
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint | ||
disable-all: true | ||
enable: | ||
- deadcode | ||
- depguard | ||
- dogsled | ||
- errcheck | ||
- gochecknoinits | ||
- goconst | ||
- gocritic | ||
- gocyclo | ||
- gofmt | ||
- goimports | ||
- revive | ||
- gosec | ||
- gosimple | ||
- govet | ||
- ineffassign | ||
- nakedret | ||
- staticcheck | ||
- structcheck | ||
- stylecheck | ||
- typecheck | ||
- unconvert | ||
- unused | ||
- varcheck | ||
- whitespace | ||
- gocognit | ||
- prealloc | ||
|
||
issues: | ||
exclude-rules: | ||
- path: \.go | ||
linters: | ||
- typecheck | ||
- path: _test\.go | ||
linters: | ||
- gocyclo | ||
- errcheck | ||
- dupl | ||
- gosec | ||
- typecheck | ||
new: false | ||
|
||
# golangci.com configuration | ||
# https://github.com/golangci/golangci/wiki/Configuration | ||
service: | ||
golangci-lint-version: 1.43.x # use the fixed version to not introduce new linters unexpectedly | ||
prepare: | ||
- echo "here I can run custom commands, but no preparation needed for this repo" |
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,4 @@ | ||
# Skip for indirect dependency github.com/gorilla/[email protected] | ||
# Used by github.com/gorilla/mux v1.8.0 | ||
# For more info: https://ossindex.sonatype.org/vulnerability/sonatype-2021-4899?component-type=golang&component-name=github.com%2Fgorilla%2Fsessions&utm_source=nancy-client&utm_medium=integration&utm_content=1.0.33 | ||
sonatype-2021-4899 |
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,9 @@ | ||
Contributing guidelines | ||
======================= | ||
|
||
### Git workflow | ||
|
||
* We use git-flow - create a feature branch from `develop`, e.g. `feature/new-feature` | ||
* Pull requests must contain a succinct, clear summary of what the user need is driving this feature change | ||
* Ensure your branch contains logical atomic commits before sending a pull request - follow the [alphagov Git styleguide](https://github.com/alphagov/styleguides/blob/master/git.md) | ||
* You may rebase your branch after feedback if it's to include relevant updates from the develop branch. We prefer a rebase here to a merge commit as we prefer a clean and straight history on develop with discrete merge commits for features |
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,7 @@ | ||
FROM onsdigital/dp-concourse-tools-ubuntu | ||
|
||
WORKDIR /app/ | ||
|
||
COPY dp-search-reindex-tracker . | ||
|
||
CMD ./dp-search-reindex-tracker |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2022 ONS Digital | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,44 @@ | ||
BINPATH ?= build | ||
|
||
BUILD_TIME=$(shell date +%s) | ||
GIT_COMMIT=$(shell git rev-parse HEAD) | ||
VERSION ?= $(shell git tag --points-at HEAD | grep ^v | head -n 1) | ||
|
||
LDFLAGS = -ldflags "-X main.BuildTime=$(BUILD_TIME) -X main.GitCommit=$(GIT_COMMIT) -X main.Version=$(VERSION)" | ||
|
||
.PHONY: all | ||
all: audit test build | ||
|
||
.PHONY: audit | ||
audit: | ||
go list -m all | nancy sleuth | ||
|
||
.PHONY: build | ||
build: | ||
go build -tags 'production' $(LDFLAGS) -o $(BINPATH)/dp-search-reindex-tracker | ||
|
||
.PHONY: convey | ||
convey: | ||
goconvey ./... | ||
|
||
.PHONY: debug | ||
debug: | ||
go build -tags 'debug' $(LDFLAGS) -o $(BINPATH)/dp-search-reindex-tracker | ||
HUMAN_LOG=1 DEBUG=1 $(BINPATH)/dp-search-reindex-tracker | ||
|
||
.PHONY: lint | ||
lint: | ||
go install github.com/golangci/golangci-lint/cmd/[email protected] | ||
golangci-lint run ./... | ||
|
||
.PHONY: produce | ||
produce: | ||
HUMAN_LOG=1 go run cmd/producer/main.go | ||
|
||
.PHONY: test | ||
test: | ||
go test -race -cover ./... | ||
|
||
.PHONY: test-component | ||
test-component: | ||
go test -cover -coverpkg=github.com/ONSdigital/dp-search-reindex-tracker/... -component |
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 |
---|---|---|
@@ -1,2 +1,54 @@ | ||
# dp-search-reindex-tracker | ||
dp-search-reindex-tracker tracks a search reindex job | ||
|
||
### Getting started | ||
|
||
* Run `make debug` | ||
|
||
The service runs in the background consuming messages from Kafka. | ||
An example event can be created using the helper script, `make produce`. | ||
|
||
### Dependencies | ||
|
||
* Requires running… | ||
* [kafka](https://github.com/ONSdigital/dp/blob/main/guides/INSTALLING.md#prerequisites) | ||
* No further dependencies other than those defined in `go.mod` | ||
|
||
### Configuration | ||
|
||
| Environment variable | Default | Description | ||
| ---------------------------- | --------------------------------- | ----------- | ||
| BIND_ADDR | localhost:28500 | The host and port to bind to | ||
| GRACEFUL_SHUTDOWN_TIMEOUT | 5s | The graceful shutdown timeout in seconds (`time.Duration` format) | ||
| HEALTHCHECK_INTERVAL | 30s | Time between self-healthchecks (`time.Duration` format) | ||
| HEALTHCHECK_CRITICAL_TIMEOUT | 90s | Time to wait until an unhealthy dependent propagates its state to make this app unhealthy (`time.Duration` format) | ||
| KAFKA_ADDR | "localhost:9092" | The address of Kafka (accepts list) | ||
| KAFKA_OFFSET_OLDEST | true | Start processing Kafka messages in order from the oldest in the queue | ||
| KAFKA_NUM_WORKERS | 1 | The maximum number of parallel kafka consumers | ||
| KAFKA_SEC_PROTO | _unset_ | if set to `TLS`, kafka connections will use TLS ([kafka TLS doc]) | ||
| KAFKA_SEC_CA_CERTS | _unset_ | CA cert chain for the server cert ([kafka TLS doc]) | ||
| KAFKA_SEC_CLIENT_KEY | _unset_ | PEM for the client key ([kafka TLS doc]) | ||
| KAFKA_SEC_CLIENT_CERT | _unset_ | PEM for the client certificate ([kafka TLS doc]) | ||
| KAFKA_SEC_SKIP_VERIFY | false | ignores server certificate issues if `true` ([kafka TLS doc]) | ||
| HELLO_CALLED_GROUP | dp-search-reindex-tracker | The consumer group this application to consume topic messages | ||
| HELLO_CALLED_TOPIC | hello-called | The name of the topic to consume messages from | ||
|
||
[kafka TLS doc]: https://github.com/ONSdigital/dp-kafka/tree/main/examples#tls | ||
|
||
### Healthcheck | ||
|
||
The `/health` endpoint returns the current status of the service. Dependent services are health checked on an interval defined by the `HEALTHCHECK_INTERVAL` environment variable. | ||
|
||
On a development machine a request to the health check endpoint can be made by: | ||
|
||
`curl localhost:8125/health` | ||
|
||
### Contributing | ||
|
||
See [CONTRIBUTING](CONTRIBUTING.md) for details. | ||
|
||
### License | ||
|
||
Copyright © 2022, Office for National Statistics (https://www.ons.gov.uk) | ||
|
||
Released under MIT license, see [LICENSE](LICENSE.md) for details. |
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,15 @@ | ||
--- | ||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: onsdigital/dp-concourse-tools-nancy | ||
tag: latest | ||
|
||
inputs: | ||
- name: dp-search-reindex-tracker | ||
path: dp-search-reindex-tracker | ||
|
||
run: | ||
path: dp-search-reindex-tracker/ci/scripts/audit.sh |
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,21 @@ | ||
--- | ||
|
||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: golang | ||
tag: 1.18.4 | ||
|
||
inputs: | ||
- name: dp-search-reindex-tracker | ||
|
||
outputs: | ||
- name: build | ||
|
||
caches: | ||
- path: go/ | ||
|
||
run: | ||
path: dp-search-reindex-tracker/ci/scripts/build.sh |
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,15 @@ | ||
--- | ||
|
||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: golang | ||
tag: 1.18.4 | ||
|
||
inputs: | ||
- name: dp-search-reindex-tracker | ||
|
||
run: | ||
path: dp-search-reindex-tracker/ci/scripts/component.sh |
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,15 @@ | ||
--- | ||
|
||
platform: linux | ||
|
||
image_resource: | ||
type: docker-image | ||
source: | ||
repository: golang | ||
tag: 1.18.4 | ||
|
||
inputs: | ||
- name: dp-search-reindex-tracker | ||
|
||
run: | ||
path: dp-search-reindex-tracker/ci/scripts/lint.sh |
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,5 @@ | ||
#!/bin/bash -eux | ||
|
||
pushd dp-search-reindex-tracker | ||
make audit | ||
popd |
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,6 @@ | ||
#!/bin/bash -eux | ||
|
||
pushd dp-search-reindex-tracker | ||
make build | ||
cp build/dp-search-reindex-tracker Dockerfile.concourse ../build | ||
popd |
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,5 @@ | ||
#!/bin/bash -eux | ||
|
||
pushd dp-search-reindex-tracker | ||
make test-component | ||
popd |
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,5 @@ | ||
#!/bin/bash -eux | ||
|
||
pushd dp-search-reindex-tracker | ||
make lint | ||
popd |
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,5 @@ | ||
#!/bin/bash -eux | ||
|
||
pushd dp-search-reindex-tracker | ||
make test | ||
popd |
Oops, something went wrong.