This commit is contained in:
Sergey Melnikov 2024-01-29 08:09:30 +03:00
parent 9856d04a20
commit 346e5b27b5
13 changed files with 29 additions and 29 deletions

View File

@ -3,7 +3,7 @@ services:
cassandra: cassandra:
container_name: cassandra container_name: cassandra
environment: environment:
- CASSANDRA_KEYSPACE=userprofileservice - CASSANDRA_KEYSPACE=userservice
- TABLE_NAME=users - TABLE_NAME=users
build: build:
context: . context: .
@ -16,7 +16,7 @@ services:
environment: environment:
- CASSANDRA_HOST=cassandra - CASSANDRA_HOST=cassandra
- CASSANDRA_PORT=9042 - CASSANDRA_PORT=9042
- CASSANDRA_KEYSPACE=userprofileservice - CASSANDRA_KEYSPACE=userservice
- CASSANDRA_CONSISTANCY=LOCAL_QUORUM - CASSANDRA_CONSISTANCY=LOCAL_QUORUM
- TABLE_NAME=users - TABLE_NAME=users
- BIDN_SERVICE=:8080 - BIDN_SERVICE=:8080
@ -25,7 +25,7 @@ services:
- AWS_SECRET_ACCESS_KEY=fake-secret - AWS_SECRET_ACCESS_KEY=fake-secret
- BUCKET_NAME=fake-bucket - BUCKET_NAME=fake-bucket
- AWS_ACL=public-read - AWS_ACL=public-read
build: build:
context: . context: .
dockerfile: ./docker/api/Dockerfile dockerfile: ./docker/api/Dockerfile
ports: ports:

2
go.mod
View File

@ -1,4 +1,4 @@
module userprofileservice module userservice
go 1.21.6 go 1.21.6

View File

@ -2,7 +2,7 @@ package aws
import ( import (
"io" "io"
"userprofileservice/src/utils" "userservice/src/utils"
"github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/aws/session"
) )

View File

@ -1,8 +1,8 @@
package controller package controller
import ( import (
"userprofileservice/src/model" "userservice/src/model"
"userprofileservice/src/structs" "userservice/src/structs"
"github.com/gocql/gocql" "github.com/gocql/gocql"
) )

View File

@ -6,7 +6,7 @@ package mock_controller
import ( import (
reflect "reflect" reflect "reflect"
structs "userprofileservice/src/structs" structs "userservice/src/structs"
gocql "github.com/gocql/gocql" gocql "github.com/gocql/gocql"
gomock "github.com/golang/mock/gomock" gomock "github.com/golang/mock/gomock"

View File

@ -1,8 +1,8 @@
package controller package controller
import ( import (
"userprofileservice/src/model" "userservice/src/model"
"userprofileservice/src/structs" "userservice/src/structs"
"github.com/gocql/gocql" "github.com/gocql/gocql"
) )

View File

@ -3,10 +3,10 @@ package main
import ( import (
"log" "log"
"net/http" "net/http"
"userprofileservice/src/controller" "userservice/src/controller"
"userprofileservice/src/model" "userservice/src/model"
"userprofileservice/src/utils" "userservice/src/utils"
"userprofileservice/src/view" "userservice/src/view"
) )
func main() { func main() {

View File

@ -3,9 +3,9 @@ package main
import ( import (
"log" "log"
"testing" "testing"
"userprofileservice/src/controller" "userservice/src/controller"
mock_controller "userprofileservice/src/controller/mocks" mock_controller "userservice/src/controller/mocks"
"userprofileservice/src/structs" "userservice/src/structs"
"github.com/gocql/gocql" "github.com/gocql/gocql"
"github.com/golang/mock/gomock" "github.com/golang/mock/gomock"

View File

@ -3,7 +3,7 @@ package model
import ( import (
"log" "log"
"time" "time"
"userprofileservice/src/utils" "userservice/src/utils"
"github.com/gocql/gocql" "github.com/gocql/gocql"
) )
@ -11,7 +11,7 @@ import (
func NewCassandra() *gocql.Session { func NewCassandra() *gocql.Session {
conf := gocql.NewCluster(utils.GetEnv("CASSANDRA_HOST", "cassandra")) conf := gocql.NewCluster(utils.GetEnv("CASSANDRA_HOST", "cassandra"))
conf.Port = utils.ParsePort(utils.GetEnv("CASSANDRA_PORT", "9042")) conf.Port = utils.ParsePort(utils.GetEnv("CASSANDRA_PORT", "9042"))
conf.Keyspace = utils.GetEnv("CASSANDRA_KEYSPACE", "userprofileservice") conf.Keyspace = utils.GetEnv("CASSANDRA_KEYSPACE", "userservice")
conf.Consistency = gocql.ParseConsistency(utils.GetEnv("CASSANDRA_CONSISTANCY", "LOCAL_QUORUM")) conf.Consistency = gocql.ParseConsistency(utils.GetEnv("CASSANDRA_CONSISTANCY", "LOCAL_QUORUM"))
sess, err := conf.CreateSession() sess, err := conf.CreateSession()
if err != nil { if err != nil {

View File

@ -1,7 +1,7 @@
package model package model
import ( import (
"userprofileservice/src/structs" "userservice/src/structs"
"github.com/gocql/gocql" "github.com/gocql/gocql"
) )

View File

@ -1,8 +1,8 @@
package model package model
import ( import (
"userprofileservice/src/structs" "userservice/src/structs"
"userprofileservice/src/utils" "userservice/src/utils"
"github.com/gocql/gocql" "github.com/gocql/gocql"
) )
@ -71,7 +71,7 @@ func (c *ModelCassandra) CreateUser(user *structs.USER) error {
// GetUser return user data by id // GetUser return user data by id
func (c *ModelCassandra) GetUser(id gocql.UUID) (*structs.USER, error) { func (c *ModelCassandra) GetUser(id gocql.UUID) (*structs.USER, error) {
q := `SELECT id, firstname, lastname, currentlocation, birthday, userpicture, certificate q := `SELECT id, firstname, lastname, currentlocation, birthday, userpicture, certificate
FROM ` + c.TableName + ` WHERE id = ? LIMIT 1` FROM ` + c.TableName + ` WHERE id = ? LIMIT 1`
user := &structs.USER{} user := &structs.USER{}

View File

@ -5,7 +5,7 @@ import (
"reflect" "reflect"
"strconv" "strconv"
"strings" "strings"
"userprofileservice/src/structs" "userservice/src/structs"
) )
// GetEnv look up ENV settings // GetEnv look up ENV settings

View File

@ -4,12 +4,12 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"net/http" "net/http"
"userprofileservice/src/aws" "userservice/src/aws"
"userprofileservice/src/controller" "userservice/src/controller"
"userprofileservice/src/structs" "userservice/src/structs"
"userprofileservice/src/utils" "userservice/src/utils"
_ "userprofileservice/src/docs" _ "userservice/src/docs"
"github.com/gocql/gocql" "github.com/gocql/gocql"
"github.com/gorilla/mux" "github.com/gorilla/mux"