Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pulling refactor/arangodb-backend into develop #184

Merged
merged 80 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
8eb451a
feat(model): add ContentDoc struct to represent a content document in…
cybersiddhu Oct 23, 2023
c85f797
chore(go.mod): add indirect dependency on github.com/arangodb/go-driv…
cybersiddhu Oct 23, 2023
fc75e28
feat(repository): add ContentRepository interface to define methods f…
cybersiddhu Oct 23, 2023
7c94896
chore(go.mod): update go-genproto dependency to v0.0.0-20231025200857…
cybersiddhu Oct 25, 2023
89876cd
chore(message): remove unused message package and nats request implem…
cybersiddhu Oct 26, 2023
2780e08
chore(model.go): add JSON schema for ContentDoc struct to enforce req…
cybersiddhu Oct 26, 2023
45033f1
feat(arangodb): add implementation for NewContentRepo function in ara…
cybersiddhu Oct 26, 2023
3a8aa4f
feat(message): add Publisher interface for managing message publishing
cybersiddhu Oct 26, 2023
df03a57
feat(nats): add nats package for publishing messages to a NATS server
cybersiddhu Oct 26, 2023
8a0445a
chore(main.go): remove main.go file
cybersiddhu Oct 26, 2023
c394dee
chore(.gitignore): remove 'modware-content' from the ignored files
cybersiddhu Oct 26, 2023
cd45685
feat(modware-content): add main.go file for modware-content microserv…
cybersiddhu Oct 26, 2023
4f7d75e
chore(content_test.go): remove unused imports and functions, clean up…
cybersiddhu Oct 27, 2023
4291b50
chore(validate.go): remove unused validate package and function
cybersiddhu Oct 27, 2023
7502cf3
chore(go.mod): update dependencies
cybersiddhu Oct 27, 2023
16e90d6
refactor(main.go): remove unused imports and function call
cybersiddhu Oct 27, 2023
7d144cf
chore(server.go): remove unused imports and functions
cybersiddhu Oct 27, 2023
a2aeae8
feat(service): add ContentService struct and its methods for handling…
cybersiddhu Oct 27, 2023
70ff500
feat(server.go): add server package and RunServer function to start t…
cybersiddhu Oct 27, 2023
942a4ff
refactor(arangodb.go): change schemaOptions variable declaration to u…
cybersiddhu Oct 27, 2023
52ea371
feat(arangodb.go): add import statement for content package from go-g…
cybersiddhu Oct 27, 2023
7b8d3be
feat(arangodb.go): add creation of unique index for slug and namespac…
cybersiddhu Oct 27, 2023
b799759
chore(README.md): remove all-contributors section and newline at end …
cybersiddhu Oct 27, 2023
e783bf8
fix(arangodb.go): update index names and fields in EnsurePersistentIn…
cybersiddhu Oct 27, 2023
624a0e8
refactor(service.go): rename Params struct field 'Publisher' to 'Mess…
cybersiddhu Oct 27, 2023
631f5f7
fix(repository): change parameter name from 'id' to 'slug' in GetCont…
cybersiddhu Oct 27, 2023
0030f06
feat(model.go): add NotFound field to ContentDoc struct to indicate i…
cybersiddhu Oct 27, 2023
e74bed6
feat(arangodb): add ContentFindBySlug statement to retrieve content b…
cybersiddhu Oct 27, 2023
2c0893a
feat(arangodb.go): implement GetContentBySlug function to retrieve co…
cybersiddhu Oct 27, 2023
f2ebe8c
feat(arangodb.go): implement GetContent method to retrieve content by ID
cybersiddhu Oct 30, 2023
68735b4
fix(arangodb.go): handle not found error when reading document and re…
cybersiddhu Oct 30, 2023
514224a
feat(arangodb.go): implement DeleteContent method in arangorepository
cybersiddhu Oct 30, 2023
ed46e2f
chore(go.mod): update go-genproto dependency to v0.0.0-20231030202356…
cybersiddhu Oct 30, 2023
f7c94c8
feat(arangodb): add ContentInsert statement to handle inserting conte…
cybersiddhu Oct 30, 2023
7c74851
feat(arangodb.go): implement AddContent method to add new content to …
cybersiddhu Oct 30, 2023
ca8417e
feat(statement.go): add ContentUpdate statement for updating content …
cybersiddhu Oct 30, 2023
5ff5880
feat(arangodb.go): implement EditContent function to update content i…
cybersiddhu Oct 30, 2023
28bdb6e
feat(arangodb.go): add parameter 'cid' to EditContent function for sp…
cybersiddhu Oct 30, 2023
b1c3604
refactor(repository.go): rename parameter 'id' to 'cid' in GetContent…
cybersiddhu Oct 30, 2023
7c8e34a
fix(arangodb.go): change GetContent and DeleteContent functions to ac…
cybersiddhu Oct 30, 2023
65b75eb
feat(repository): add Dbh method to ContentRepository interface to pr…
cybersiddhu Oct 31, 2023
4921285
feat(arangodb.go): add Dbh method to retrieve the ArangoDB database h…
cybersiddhu Oct 31, 2023
ad10c3a
test(arangodb_test.go): add test file for ArangoDB repository impleme…
cybersiddhu Oct 31, 2023
f331b9f
feat(model.go): add Slugify function to generate slugs from names
cybersiddhu Oct 31, 2023
9a342ab
refactor(arangodb.go): add @content_collection attribute to content i…
cybersiddhu Oct 31, 2023
b87a0bb
test(arangodb_test.go): add unit test for adding content to the repos…
cybersiddhu Oct 31, 2023
d5f8a3a
test(arangodb_test.go): add assertions to test the content attributes…
cybersiddhu Oct 31, 2023
b6fa80c
test(arangodb_test.go): add test case for getting content by slug
cybersiddhu Nov 1, 2023
e92827f
test(arangodb_test.go): add testContentProperties function to improve…
cybersiddhu Nov 1, 2023
3cc659b
test(arangodb_test.go): add new test case TestGetContent to retrieve …
cybersiddhu Nov 1, 2023
8a9fa33
fix(arangodb.go): refactor error handling in GetContent function
cybersiddhu Nov 1, 2023
8cf1b26
test(arangodb_test.go): add test case for deleting content
cybersiddhu Nov 1, 2023
dc5ee92
fix(arangodb.go): convert cid to string before passing it to the Cont…
cybersiddhu Nov 1, 2023
2ccd0f0
test(arangodb_test.go): add test case for editing content
cybersiddhu Nov 1, 2023
9168f06
test(arangodb_test.go): add test for schema validation in the repository
cybersiddhu Nov 1, 2023
a0288c3
chore(go.mod): update dependencies and Go version
cybersiddhu Nov 1, 2023
eff52d4
chore(go.mod): update google.golang.org/grpc to v1.59.0
cybersiddhu Nov 2, 2023
464e9bc
feat(service.go): add implementation for GetContentBySlug method
cybersiddhu Nov 2, 2023
81b5074
feat(service.go): add buildContent function to build content object, …
cybersiddhu Nov 2, 2023
12721b8
feat(service.go): implement logic to add content to repository in Sto…
cybersiddhu Nov 2, 2023
41be3a1
feat(service.go): implement UpdateContent method in ContentService
cybersiddhu Nov 2, 2023
f67c07d
fix(service.go): add input validation and error handling for DeleteCo…
cybersiddhu Nov 3, 2023
e93b805
feat(service.go): add publishing of content creation and update events
cybersiddhu Nov 3, 2023
2c3695f
feat(testutils): add test utility functions for creating and parsing …
cybersiddhu Nov 6, 2023
8b8dadd
test(arangodb_test.go): update test cases to use helper functions fro…
cybersiddhu Nov 6, 2023
ab9cc96
fix(server.go): fix import statement for go-genproto/dictybaseapis/an…
cybersiddhu Nov 7, 2023
6cb7dd7
feat(service_test.go): add unit test for setup function
cybersiddhu Nov 7, 2023
9c52a19
test(service_test.go): add unit test for StoreContent function
cybersiddhu Nov 7, 2023
401d841
test(service_test.go): add testContentProperties function to compare …
cybersiddhu Nov 7, 2023
2b9e5fa
test(service_test.go): add test case for getting content by slug
cybersiddhu Nov 7, 2023
6ed5e73
test(service_test.go): add new test case TestGetContent to test fetch…
cybersiddhu Nov 7, 2023
9f4d1bc
test(service_test.go): add test case for updating content
cybersiddhu Nov 7, 2023
beec105
test(service_test.go): add test case for deleting content
cybersiddhu Nov 7, 2023
1086cc5
refactor(server.go): reformat code to improve readability and maintai…
cybersiddhu Nov 7, 2023
655ebdf
fix(server.go): fix import path for aphgrpc package
cybersiddhu Nov 7, 2023
3f1bb71
chore(testcov.yml): update service to use ArangoDB instead of Postgre…
cybersiddhu Nov 7, 2023
f075af4
chore(ci.yml): update service configuration for arangodb in CI workflow
cybersiddhu Nov 7, 2023
6940210
chore(go.mod): remove unused dependencies and update versions
cybersiddhu Nov 7, 2023
2daa785
chore(Dockerfile): reorganize ADD statements to improve readability a…
cybersiddhu Nov 7, 2023
93c10f9
chore(.golangci.yml): update linters configuration to exclude G402 an…
cybersiddhu Nov 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,31 +7,26 @@ jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:9.6.6-alpine
arangodb:
image: arangodb:3.10.9
env:
POSTGRES_DB: pgtest
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgdocker
ARANGO_ROOT_PASSWORD: rootpass
ports:
- 5432/tcp
- 8529/tcp
steps:
- name: set up golang
uses: actions/setup-go@v4
with:
go-version: '~1.20.6'
- name: check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: unit test
run: go test -covermode=atomic -coverprofile=profile.cov -v ./...
run: go test -parallel 4 -covermode=atomic -coverprofile=profile.cov -v ./...
env:
POSTGRES_DB: pgtest
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgdocker
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
NATS_HOST: localhost
NATS_PORT: ${{ job.services.nats.ports[4222] }}
ARANGO_USER: root
ARANGO_PASS: rootpass
ARANGO_HOST: localhost
ARANGO_PORT: ${{ job.services.arangodb.ports[8529] }}
GOPROXY: https://proxy.golang.org
- name: upload coverage to codecov
uses: codecov/codecov-action@v3
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/testcov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,26 @@ jobs:
test:
runs-on: ubuntu-latest
services:
postgres:
image: postgres:9.6.6-alpine
arangodb:
image: arangodb:3.10.9
env:
POSTGRES_DB: pgtest
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgdocker
ARANGO_ROOT_PASSWORD: rootpass
ports:
- 5432/tcp
- 8529/tcp
steps:
- name: set up golang
uses: actions/setup-go@v4
with:
go-version: '~1.20.6'
- name: check out code
uses: actions/checkout@v4
uses: actions/checkout@v3
- name: unit test
run: go test -covermode=atomic -coverprofile=profile.cov -v ./...
run: go test -parallel 4 -covermode=atomic -coverprofile=profile.cov -v ./...
env:
POSTGRES_DB: pgtest
POSTGRES_USER: pguser
POSTGRES_PASSWORD: pgdocker
POSTGRES_HOST: localhost
POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
NATS_HOST: localhost
NATS_PORT: ${{ job.services.nats.ports[4222] }}
ARANGO_USER: root
ARANGO_PASS: rootpass
ARANGO_HOST: localhost
ARANGO_PORT: ${{ job.services.arangodb.ports[8529] }}
GOPROXY: https://proxy.golang.org
- name: upload coverage to codecov
uses: codecov/codecov-action@v3
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
vendor/
modware-content
34 changes: 3 additions & 31 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ run:
linters-settings:
funlen:
lines: 80
statements: 50
lll:
line-length: 130
revive:
rules:
- name: var-naming
arguments: [["ID"]]
gosec:
excludes:
- G404
- G402
wrapcheck:
ignoreSigs:
- .HandleMessagingError(
Expand All @@ -36,57 +34,31 @@ linters:
- bodyclose
- bidichk
- cyclop
- decorder
- depguard
- decorder
- dogsled
- dupl
# - dupl
- errcheck
- errname
- funlen
- gci
- gochecknoinits
- goconst
- gocritic
- gocyclo
- godot
- gofmt
- goimports
- gosec
- gosimple
- govet
- gocognit
- gomnd
- gomoddirectives
- gomodguard
- grouper
- ineffassign
- importas
- lll
- maintidx
- misspell
- nakedret
- nestif
- nilerr
- nlreturn
- nolintlint
- prealloc
# - paralleltest
- predeclared
- revive
- rowserrcheck
- staticcheck
- typecheck
- unconvert
- thelper
- tparallel
- unparam
- unused
- unconvert
- unparam
- varnamelen
- wastedassign
- whitespace
- wrapcheck

# don't enable:
# - godox
Expand Down
23 changes: 0 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
# modware-user
<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->
[![All Contributors](https://img.shields.io/badge/all_contributors-2-orange.svg?style=flat-square)](#contributors-)
<!-- ALL-CONTRIBUTORS-BADGE:END -->

[![License](https://img.shields.io/badge/License-BSD%202--Clause-blue.svg)](LICENSE)
![Continuous integration](https://github.com/dictyBase/modware-content/workflows/Continuous%20integration/badge.svg)
[![codecov](https://codecov.io/gh/dictyBase/modware-content/branch/develop/graph/badge.svg)](https://codecov.io/gh/dictyBase/modware-content)
Expand Down Expand Up @@ -68,22 +64,3 @@ The protocol buffer definitions and service apis are documented
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/dictyBase/modware-content?style=plastic)
[![Lines of Code](https://badgen.net/codeclimate/loc/dictyBase/modware-content)](https://codeclimate.com/github/dictyBase/modware-content/code)

## Contributors ✨

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tr>
<td align="center"><a href="http://cybersiddhu.github.com/"><img src="https://avatars3.githubusercontent.com/u/48740?v=4" width="100px;" alt=""/><br /><sub><b>Siddhartha Basu</b></sub></a><br /><a href="https://github.com/dictyBase/modware-content/issues?q=author%3Acybersiddhu" title="Bug reports">🐛</a> <a href="https://github.com/dictyBase/modware-content/commits?author=cybersiddhu" title="Code">💻</a> <a href="#content-cybersiddhu" title="Content">🖋</a> <a href="https://github.com/dictyBase/modware-content/commits?author=cybersiddhu" title="Documentation">📖</a> <a href="#maintenance-cybersiddhu" title="Maintenance">🚧</a></td>
<td align="center"><a href="http://www.erichartline.net/"><img src="https://avatars3.githubusercontent.com/u/13489381?v=4" width="100px;" alt=""/><br /><sub><b>Eric Hartline</b></sub></a><br /><a href="https://github.com/dictyBase/modware-content/issues?q=author%3Awildlifehexagon" title="Bug reports">🐛</a> <a href="https://github.com/dictyBase/modware-content/commits?author=wildlifehexagon" title="Code">💻</a> <a href="#content-wildlifehexagon" title="Content">🖋</a> <a href="https://github.com/dictyBase/modware-content/commits?author=wildlifehexagon" title="Documentation">📖</a> <a href="#maintenance-wildlifehexagon" title="Maintenance">🚧</a></td>
</tr>
</table>

<!-- markdownlint-enable -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
6 changes: 2 additions & 4 deletions build/package/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ COPY go.mod ./
COPY go.sum ./
COPY main.go ./
RUN go mod download
ADD server server
ADD commands commands
ADD message message
ADD validate validate
ADD cmd cmd
ADD internal internal
RUN go build \
-a \
-ldflags "-s -w -extldflags '-static'" \
Expand Down
65 changes: 65 additions & 0 deletions cmd/modware-content/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package main

import (
"log"
"os"

apiflag "github.com/dictyBase/aphgrpc"
arangoflag "github.com/dictyBase/arangomanager/command/flag"
"github.com/dictyBase/modware-content/internal/app/server"
"github.com/urfave/cli"
)

func main() {
app := cli.NewApp()
app.Name = "modware-content"
app.Usage = "cli for modware-content microservice"
app.Version = "2.0.0"
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "log-format",
Usage: "format of the logging out, either of json or text.",
Value: "json",
},
cli.StringFlag{
Name: "log-level",
Usage: "log level for the application",
Value: "error",
},
}
app.Commands = []cli.Command{
{
Name: "start-server",
Usage: "starts the modware-content microservice with HTTP and grpc backends",
Action: server.RunServer,
Flags: getServerFlags(),
},
}
if err := app.Run(os.Args); err != nil {
log.Fatalf("error in running command %s", err)
}
}

func getServerFlags() []cli.Flag {
flg := []cli.Flag{
cli.StringFlag{
Name: "port",
Usage: "tcp port at which the server will be available",
Value: "9560",
},
cli.StringFlag{
Name: "content-collection",
Usage: "arangodb collection for storing editor data",
Value: "serialized_json",
},
cli.StringFlag{
Name: "arangodb-database, db",
EnvVar: "ARANGODB_DATABASE",
Usage: "arangodb database name",
Value: "content",
},
}
flg = append(flg, arangoflag.ArangoFlags()...)

return append(flg, apiflag.NatsFlag()...)
}
Loading
Loading