Compare commits

...
This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.

1 Commits

Author SHA1 Message Date
cce1a01369 feat(postgres): enable postgres support 2024-06-21 13:16:50 +02:00
5 changed files with 47 additions and 21 deletions

12
go.mod
View File

@ -3,19 +3,19 @@ module git.dragse.it/anthrove/plug-sdk
go 1.22.0
require (
git.dragse.it/anthrove/otter-space-sdk v1.0.0
github.com/matoous/go-nanoid/v2 v2.0.0
git.dragse.it/anthrove/otter-space-sdk v1.5.1-0.20240620204503-84aee5c2dda5
github.com/matoous/go-nanoid/v2 v2.1.0
google.golang.org/grpc v1.61.1
google.golang.org/protobuf v1.32.0
google.golang.org/protobuf v1.33.0
)
require (
github.com/golang/protobuf v1.5.3 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/neo4j/neo4j-go-driver/v5 v5.17.0 // indirect
github.com/sirupsen/logrus v1.9.3 // indirect
github.com/stretchr/testify v1.8.4 // indirect
github.com/stretchr/testify v1.9.0 // indirect
golang.org/x/net v0.21.0 // indirect
golang.org/x/sys v0.17.0 // indirect
golang.org/x/sys v0.19.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17 // indirect
)

7
go.sum
View File

@ -1,17 +1,21 @@
git.dragse.it/anthrove/otter-space-sdk v1.0.0 h1:sJ5d8yMFAosP9+315PxZc5yzYUdzAJEEyxoKDmc8YoE=
git.dragse.it/anthrove/otter-space-sdk v1.0.0/go.mod h1:QI2W7gm1GflcAeipEoyLZ3hj86DlIgwT9Lisc4c99Vs=
git.dragse.it/anthrove/otter-space-sdk v1.5.1-0.20240620204503-84aee5c2dda5 h1:xAJTbLW4imPFh2E1aEZo5+hQk0DKqK95iicIicWfDKM=
git.dragse.it/anthrove/otter-space-sdk v1.5.1-0.20240620204503-84aee5c2dda5/go.mod h1:28gC8KJzILQOztRCo/qvUOqdiTCyeMc2xgSgEfGr8m8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/matoous/go-nanoid v1.5.0/go.mod h1:zyD2a71IubI24efhpvkJz+ZwfwagzgSO6UNiFsZKN7U=
github.com/matoous/go-nanoid/v2 v2.0.0 h1:d19kur2QuLeHmJBkvYkFdhFBzLoo1XVm2GgTpL+9Tj0=
github.com/matoous/go-nanoid/v2 v2.0.0/go.mod h1:FtS4aGPVfEkxKxhdWPAspZpZSh1cOjtM7Ej/So3hR0g=
github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM=
github.com/neo4j/neo4j-go-driver/v5 v5.17.0 h1:Bdqg1Y8Hd3uLYToXtBjysDYXTdMiP7zeUNUEwfbJkSo=
github.com/neo4j/neo4j-go-driver/v5 v5.17.0/go.mod h1:Vff8OwT7QpLm7L2yYr85XNWe9Rbqlbeb9asNXJTHO4k=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
@ -23,11 +27,13 @@ github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
golang.org/x/net v0.21.0 h1:AQyQV4dYCvJ7vGmJyKki9+PBdyvhkSd8EIx/qb0AYv4=
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.17.0 h1:25cE3gD+tdBA7lp7QfhuV+rJiE9YXTcS3VG1SqssI/Y=
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
@ -39,6 +45,7 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
google.golang.org/protobuf v1.32.0 h1:pPC6BG5ex8PDFnkbrGU3EixyhKcQ2aDuBS36lqK/C7I=
google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=

View File

@ -2,16 +2,34 @@ package otter
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/graph"
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
)
func ConnectToDatabase(ctx context.Context, endpoint string, username string, password string, debug bool) (graph.OtterSpace, error) {
var graphConnection graph.OtterSpace
func ConnectToGraphDatabase(ctx context.Context, endpoint string, username string, password string, debug bool) (database.OtterSpace, error) {
var graphConnection database.OtterSpace
var err error
graphConnection = graph.NewGraphConnection(debug)
err = graphConnection.Connect(ctx, endpoint, username, password)
graphConnection = database.NewGraphConnection(debug)
err = graphConnection.Connect(ctx, endpoint, username, password, "", 0, "", "")
if err != nil {
return nil, err
}
return graphConnection, err
}
func ConnectToPostgresDatabase(ctx context.Context, endpoint string, username string, password string, databaseName string, port int, ssl bool, timezone string, debug bool) (database.OtterSpace, error) {
var graphConnection database.OtterSpace
var err error
var sslString string
graphConnection = database.NewPostgresqlConnection(debug)
if ssl {
sslString = "disable"
} else {
sslString = "require"
}
err = graphConnection.Connect(ctx, endpoint, username, password, databaseName, port, sslString, timezone)
if err != nil {
return nil, err
}

View File

@ -2,10 +2,11 @@ package plug
import (
"context"
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
"google.golang.org/protobuf/types/known/timestamppb"
"log"
"git.dragse.it/anthrove/otter-space-sdk/pkg/graph"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
gRPC "git.dragse.it/anthrove/plug-sdk/pkg/grpc"
gonanoid "github.com/matoous/go-nanoid/v2"
@ -14,11 +15,11 @@ import (
type server struct {
gRPC.UnimplementedPlugConnectorServer
ctx map[string]context.CancelFunc
database graph.OtterSpace
database database.OtterSpace
taskExecutionFunction TaskExecution
}
func NewGrpcServer(database graph.OtterSpace, taskExecutionFunction TaskExecution) gRPC.PlugConnectorServer {
func NewGrpcServer(database database.OtterSpace, taskExecutionFunction TaskExecution) gRPC.PlugConnectorServer {
return &server{
ctx: make(map[string]context.CancelFunc),
database: database,
@ -27,7 +28,7 @@ func NewGrpcServer(database graph.OtterSpace, taskExecutionFunction TaskExecutio
}
func (s *server) TaskStart(ctx context.Context, creation *gRPC.PlugTaskCreation) (*gRPC.PlugTaskStatus, error) {
var anthroveUser models.AnthroveUser
var anthroveUser graphModels.AnthroveUser
var plugTaskState gRPC.PlugTaskStatus
var err error

View File

@ -3,21 +3,21 @@ package plug
import (
"context"
"fmt"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models"
"git.dragse.it/anthrove/otter-space-sdk/pkg/database"
"git.dragse.it/anthrove/otter-space-sdk/pkg/models/graphModels"
"net"
"git.dragse.it/anthrove/otter-space-sdk/pkg/graph"
pb "git.dragse.it/anthrove/plug-sdk/pkg/grpc"
"google.golang.org/grpc"
)
type TaskExecution func(ctx context.Context, graph graph.OtterSpace, sourceUsername string, anthroveUser models.AnthroveUser, deepScrape bool, cancelFunction func()) error
type TaskExecution func(ctx context.Context, graph database.OtterSpace, sourceUsername string, anthroveUser graphModels.AnthroveUser, deepScrape bool, cancelFunction func()) error
type Server struct {
address string
port string
ctx context.Context
database graph.OtterSpace
database database.OtterSpace
taskExecutionFunction TaskExecution
}
@ -49,7 +49,7 @@ func (s *Server) Listen() error {
return nil
}
func (s *Server) WithGraphConnection(graph graph.OtterSpace) {
func (s *Server) WithGraphConnection(graph database.OtterSpace) {
s.database = graph
}