Skip to content

Commit

Permalink
refactor(fivetran_sdk): Create a separate folder for V1 examples (#79)
Browse files Browse the repository at this point in the history
* create folder for v1 examples

* gitignore changes

* readme changes

* add proto files to parent folder

* fix(github_workflow): update the workflow

* argument change

---------

Co-authored-by: Satvik Patil <[email protected]>
Co-authored-by: Varun Dhall <[email protected]>
  • Loading branch information
3 people authored Jan 2, 2025
1 parent 58b7aa3 commit 09a813c
Show file tree
Hide file tree
Showing 56 changed files with 411 additions and 35 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/audit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ jobs:
run: python -m pip install --upgrade pip setuptools wheel

- name: Install Python connector requirements
working-directory: examples/connector/python
working-directory: v1_examples/connector/python
run: pip install -r requirements.txt

- name: Run Python connector build script
working-directory: examples/connector/python
working-directory: v1_examples/connector/python
run: ./build.sh

- name: Install Python destination requirements
working-directory: examples/destination/python
working-directory: v1_examples/destination/python
run: pip install -r requirements.txt

- name: Run Python destination build script
working-directory: examples/destination/python
working-directory: v1_examples/destination/python
run: ./build.sh

- name: Set up Go
Expand All @@ -58,45 +58,45 @@ jobs:
version: "23.2"

- name: Set up protobuf for Go
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: go install google.golang.org/protobuf/cmd/[email protected]

- name: Set up protoc-gen-go
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: go install google.golang.org/grpc/cmd/[email protected]

- name: Set up Go protoc path
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: export PATH="$PATH:$(go env GOPATH)/bin"

- name: Verify dependencies
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: go mod verify

- name: Build Go connector
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: scripts/build.sh

- name: Run go vet
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: go vet ./...

- name: Install staticcheck
run: go install honnef.co/go/tools/cmd/staticcheck@latest

- name: Run staticcheck
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: staticcheck ./...

- name: Install golint
run: go install golang.org/x/lint/golint@latest

- name: Run golint
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: golint ./...

- name: Run tests
working-directory: examples/connector/golang
working-directory: v1_examples/connector/golang
run: go test -race -vet=off ./...

- name: Setup Gradle
Expand All @@ -105,17 +105,17 @@ jobs:
gradle-version: 8.5

- name: Run Java connector copyProtos
working-directory: examples/connector/java
working-directory: v1_examples/connector/java
run: gradle copyProtos

- name: Run Java connector test with Gradle Wrapper
working-directory: examples/connector/java
working-directory: v1_examples/connector/java
run: gradle build

- name: Run Java destination copyProtos
working-directory: examples/destination/java
working-directory: v1_examples/destination/java
run: gradle copyProtos

- name: Run Java destination test with Gradle Wrapper
working-directory: examples/destination/java
working-directory: v1_examples/destination/java
run: gradle build
14 changes: 7 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
**/build/
**/golang/main
bin/*
examples/**/*.proto
examples/**/*.pb.go
examples/**/*pb2.py
examples/**/*pb2.pyi
examples/**/*pb2_grpc.py
v1_examples/*/**/*.proto
v1_examples/**/*.pb.go
v1_examples/**/*pb2.py
v1_examples/**/*pb2.pyi
v1_examples/**/*pb2_grpc.py
destination_run/
connector_run/
**/__pycache__/
examples/**/node_modules/
examples/**/package-lock.json
v1_examples/**/node_modules/
v1_examples/**/package-lock.json
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ A way for partners to create connectors and destinations that run on [Fivetran

## Repo Structure
This repo consists of example connectors and destinations along with a local testing environment. Connectors and destinations are written in a [gRPC supported language](https://grpc.io/docs/languages/) that can generate a statically linked binary. We recommend Java, Golang, or Rust.
* [Examples](examples/)
* [Examples](v1_examples/)
* [Local Testing Tools](tools/)

## Development
Expand Down
1 change: 0 additions & 1 deletion examples/connector/golang/scripts/copy_protos.sh

This file was deleted.

2 changes: 1 addition & 1 deletion tools/connector-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Pre-requisites
- Docker Desktop >= 4.23.0 or [Rancher Desktop](https://rancherdesktop.io/) >= 1.12.1
- gRPC server is running for the particular example (see [example readme's](/examples/connector/))
- gRPC server is running for the particular example (see [example readme's](/v1_examples/connector/))

## How To Run

Expand Down
2 changes: 1 addition & 1 deletion tools/destination-tester/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Pre-requisites
- Docker Desktop >= 4.23.0 or [Rancher Desktop](https://rancherdesktop.io/) >= 1.12.1
- gRPC server is running for the particular example (see [example readme's](/examples/destination/))
- gRPC server is running for the particular example (see [example readme's](/v1_examples/destination/))

## How To Run

Expand Down
133 changes: 133 additions & 0 deletions v1_examples/common.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
syntax = "proto3";
option optimize_for = SPEED;
option java_multiple_files = true;
option go_package = "fivetran.com/fivetran_sdk";
package fivetran_sdk;

import "google/protobuf/timestamp.proto";

message ConfigurationFormRequest {}

message ConfigurationFormResponse {
bool schema_selection_supported = 1;
bool table_selection_supported = 2;
repeated FormField fields = 3;
repeated ConfigurationTest tests = 4;
}

message FormField {
string name = 1;
string label = 2;
bool required = 3;
optional string description = 4;
oneof type {
TextField text_field = 5;
DropdownField dropdown_field = 6;
ToggleField toggle_field = 7;
}
}

message DropdownField {
repeated string dropdown_field = 1;
}

message ToggleField {}

enum TextField {
PlainText = 0;
Password = 1;
Hidden = 2;
}

message ConfigurationTest {
string name = 1; // unique identifier for the test
string label = 2; // A few words indicating what we are testing, e.g. 'Connecting to database'
}

message TestRequest {
string name = 1;
map<string, string> configuration = 2;
}

message TestResponse {
oneof response {
bool success = 1;
string failure = 2;
// potential future warning
}
}

message SchemaList {
repeated Schema schemas = 1;
}

message TableList {
repeated Table tables = 1;
}

message Schema {
string name = 1;
repeated Table tables = 2;
}

enum DataType {
UNSPECIFIED = 0;
BOOLEAN = 1;
SHORT = 2;
INT = 3;
LONG = 4;
DECIMAL = 5;
FLOAT = 6;
DOUBLE = 7;
NAIVE_DATE = 8;
NAIVE_DATETIME = 9;
UTC_DATETIME = 10;
BINARY = 11;
XML = 12;
STRING = 13;
JSON = 14;
}

message DecimalParams {
uint32 precision = 1;
uint32 scale = 2;
}

enum OpType {
UPSERT = 0;
UPDATE = 1;
DELETE = 2;
TRUNCATE = 3;
}

message ValueType {
oneof inner {
bool null = 1;
bool bool = 2;
int32 short = 3;
int32 int = 4;
int64 long = 5;
float float = 6;
double double = 7;
google.protobuf.Timestamp naive_date = 8;
google.protobuf.Timestamp naive_datetime = 9;
google.protobuf.Timestamp utc_datetime = 10;
string decimal = 11;
bytes binary = 12;
string string = 13;
string json = 14;
string xml = 15;
}
}

message Table {
string name = 1;
repeated Column columns = 2;
}

message Column {
string name = 1;
DataType type = 2;
bool primary_key = 3;
optional DecimalParams decimal = 4;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Run all commands from the golang folder root

## Steps
```
> cd examples/connector/golang
> cd v1_examples/connector/golang
> scripts/copy_protos.sh
> scripts/compile_protos.sh
> scripts/build.sh
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (s *server) Update(in *pb.UpdateRequest, stream pb.Connector_UpdateServer)
state := MyState{}
json.Unmarshal([]byte(state_json), &state)

message := fmt.Sprintf("config: %s, selection: %s, state_json: %s, mystate: %s", config, selection, state_json, state)
message := fmt.Sprintf("config: %s, selection: %s, state_json: %s, mystate: %+v", config, selection, state_json, state)
LogMessage(INFO, message)

// -- Send a log message
Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions v1_examples/connector/golang/scripts/copy_protos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cp ../../*.proto proto/
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ application {
}

tasks.register('copyProtos', Copy) {
from file("$rootDir/../../..")
from file("$rootDir/../..")
into file("src/main/proto/")
include "*.proto"
}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ mkdir -p protos

# Copy all .proto files from the parent directory (5 levels up) to the 'protos' directory.
# These files are used for defining the gRPC services and messages.
cp ../../../../*.proto protos/
cp ../../../*.proto protos/

# Return to the previous directory (the project root).
cd ..
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pip install -r requirements.txt

# copying protos present in the root of directory to `protos` folder
mkdir -p protos
cp ../../../*.proto protos/
cp ../../*.proto protos/
# Generates the required gRPC Python files using protos into `sdk_pb2` folder
mkdir -p sdk_pb2
python -m grpc_tools.protoc \
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 09a813c

Please sign in to comment.