fix: wrong user
This commit is contained in:
parent
7ce3b94756
commit
117c15e371
98
README.md
98
README.md
@ -1,49 +1,49 @@
|
||||
# Anthrove Plug SDK
|
||||
|
||||
Anthrove Plug SDK is a Golang-based Software Development Kit (SDK) that provides a gRPC server implementation for the Anthrove system. This SDK enables users to easily set up a server, establish a database connection, and set a task execution function.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the Anthrove Plug SDK, you will need to have Go installed on your system. You can then use the go get command to fetch the SDK:
|
||||
|
||||
```bash
|
||||
go get git.anthrove.art/Anthrove/plug-sdk/v3
|
||||
```
|
||||
## Usage
|
||||
|
||||
Below is a basic example of how to use the SDK:
|
||||
|
||||
````go
|
||||
import "git.anthrove.art/Anthrove/plug-sdk/v3/pkg/plug"
|
||||
|
||||
// Define what Source this Plug is used for
|
||||
source := models.Source{
|
||||
DisplayName: "e621",
|
||||
Domain: "e621.net",
|
||||
Icon: "e621.net/icon.png",
|
||||
}
|
||||
|
||||
// Create a new Plug instance
|
||||
p := plug.NewPlug(ctx, "localhost", "50051", source)
|
||||
|
||||
// Set the OtterSpace database
|
||||
p.WithOtterSpace(database)
|
||||
|
||||
// Set the task execution function
|
||||
p.TaskExecutionFunction(func(ctx context.Context, database database.OtterSpace, sourceUsername string, anthroveUser models.User, deepScrape bool, apiKey string, cancelFunction func()) error {
|
||||
// Your task execution logic here
|
||||
})
|
||||
|
||||
// Set the send message execution function
|
||||
p.SendMessageExecution(func(ctx context.Context, userSourceID string, message string) error {
|
||||
// Your message sending logic here
|
||||
})
|
||||
|
||||
// Start the server
|
||||
err := p.Listen()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
|
||||
|
||||
````
|
||||
# Anthrove Plug SDK
|
||||
|
||||
Anthrove Plug SDK is a Golang-based Software Development Kit (SDK) that provides a gRPC server implementation for the Anthrove system. This SDK enables users to easily set up a server, establish a database connection, and set a task execution function.
|
||||
|
||||
## Installation
|
||||
|
||||
To install the Anthrove Plug SDK, you will need to have Go installed on your system. You can then use the go get command to fetch the SDK:
|
||||
|
||||
```bash
|
||||
go get git.anthrove.art/Anthrove/plug-sdk/v3
|
||||
```
|
||||
## Usage
|
||||
|
||||
Below is a basic example of how to use the SDK:
|
||||
|
||||
````go
|
||||
import "git.anthrove.art/Anthrove/plug-sdk/v3/pkg/plug"
|
||||
|
||||
// Define what Source this Plug is used for
|
||||
source := models.Source{
|
||||
DisplayName: "e621",
|
||||
Domain: "e621.net",
|
||||
Icon: "e621.net/icon.png",
|
||||
}
|
||||
|
||||
// Create a new Plug instance
|
||||
p := plug.NewPlug(ctx, "localhost", "50051", source)
|
||||
|
||||
// Set the OtterSpace database
|
||||
p.WithOtterSpace(database)
|
||||
|
||||
// Set the task execution function
|
||||
p.TaskExecutionFunction(func(ctx context.Context, database database.OtterSpace, sourceUsername string, anthroveUser models.User, deepScrape bool, apiKey string, cancelFunction func()) error {
|
||||
// Your task execution logic here
|
||||
})
|
||||
|
||||
// Set the send message execution function
|
||||
p.SendMessageExecution(func(ctx context.Context, userSourceID string, message string) error {
|
||||
// Your message sending logic here
|
||||
})
|
||||
|
||||
// Start the server
|
||||
err := p.Listen()
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to start server: %v", err)
|
||||
}
|
||||
|
||||
|
||||
````
|
||||
|
@ -1,12 +1,12 @@
|
||||
package otter
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/database"
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/models"
|
||||
)
|
||||
|
||||
func ConnectToDatabase(ctx context.Context, config models.DatabaseConfig) error {
|
||||
return database.Connect(ctx, config)
|
||||
}
|
||||
package otter
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/database"
|
||||
"git.anthrove.art/Anthrove/otter-space-sdk/v3/pkg/models"
|
||||
)
|
||||
|
||||
func ConnectToDatabase(ctx context.Context, config models.DatabaseConfig) error {
|
||||
return database.Connect(ctx, config)
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
# Generate the gRPC files
|
||||
|
||||
To generate the gRPC files you need to do the following:
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
1. You need to install the [gRPC Compiler](https://grpc.io/docs/protoc-installation/)
|
||||
2. Install the Golang Plugin for the compiler
|
||||
````bash
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||
``````
|
||||
## Generate:
|
||||
1. Download the Git submodules (if you didn't clone this repo with ``git clone --recurse-submodules``)
|
||||
```bash
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
2. Edit the scripts, find the variable ``plugName`` and set its value to the name of the plug.
|
||||
|
||||
3. Depending on what OS you are running execute one of the following scripts:
|
||||
````bash
|
||||
scripts/generate_grpc_files.sh
|
||||
scripts/generate_grpc_files.ps1
|
||||
````
|
||||
# Generate the gRPC files
|
||||
|
||||
To generate the gRPC files you need to do the following:
|
||||
|
||||
## Prerequisites:
|
||||
|
||||
1. You need to install the [gRPC Compiler](https://grpc.io/docs/protoc-installation/)
|
||||
2. Install the Golang Plugin for the compiler
|
||||
````bash
|
||||
go install google.golang.org/protobuf/cmd/protoc-gen-go@v1.28
|
||||
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@v1.2
|
||||
``````
|
||||
## Generate:
|
||||
1. Download the Git submodules (if you didn't clone this repo with ``git clone --recurse-submodules``)
|
||||
```bash
|
||||
git submodule init
|
||||
git submodule update
|
||||
```
|
||||
|
||||
2. Edit the scripts, find the variable ``plugName`` and set its value to the name of the plug.
|
||||
|
||||
3. Depending on what OS you are running execute one of the following scripts:
|
||||
````bash
|
||||
scripts/generate_grpc_files.sh
|
||||
scripts/generate_grpc_files.ps1
|
||||
````
|
||||
|
@ -1,10 +1,10 @@
|
||||
New-Item -Path "pkg" -Name "grpc" -ItemType Directory -Force
|
||||
|
||||
protoc `
|
||||
--proto_path=third_party/grpc-proto `
|
||||
--go_out=pkg/grpc `
|
||||
--go_opt=paths=source_relative `
|
||||
--go-grpc_out=pkg/grpc `
|
||||
--go-grpc_opt=paths=source_relative `
|
||||
third_party/grpc-proto/*.proto `
|
||||
|
||||
New-Item -Path "pkg" -Name "grpc" -ItemType Directory -Force
|
||||
|
||||
protoc `
|
||||
--proto_path=third_party/grpc-proto `
|
||||
--go_out=pkg/grpc `
|
||||
--go_opt=paths=source_relative `
|
||||
--go-grpc_out=pkg/grpc `
|
||||
--go-grpc_opt=paths=source_relative `
|
||||
third_party/grpc-proto/*.proto `
|
||||
|
||||
|
@ -1,14 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
|
||||
mkdir -p "pkg/grpc"
|
||||
|
||||
protoc \
|
||||
--proto_path=third_party/grpc-proto \
|
||||
--go_out=pkg/grpc \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_out=pkg/grpc \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
third_party/grpc-proto/*.proto
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
export PATH="$PATH:$(go env GOPATH)/bin"
|
||||
|
||||
mkdir -p "pkg/grpc"
|
||||
|
||||
protoc \
|
||||
--proto_path=third_party/grpc-proto \
|
||||
--go_out=pkg/grpc \
|
||||
--go_opt=paths=source_relative \
|
||||
--go-grpc_out=pkg/grpc \
|
||||
--go-grpc_opt=paths=source_relative \
|
||||
third_party/grpc-proto/*.proto
|
||||
|
||||
|
@ -1,2 +1,2 @@
|
||||
sonar.projectKey=Anthrove---plug-sdk
|
||||
sonar.projectKey=Anthrove---plug-sdk
|
||||
sonar.exclusions=pkg/grpc/*
|
Loading…
Reference in New Issue
Block a user