-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.go
54 lines (42 loc) · 1.22 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package airbyte
import (
"context"
_ "embed"
"fmt"
"sync"
"google.golang.org/protobuf/types/known/structpb"
"github.com/instill-ai/component/pkg/base"
)
//go:embed config/definition.json
var definitionJSON []byte
//go:embed config/tasks.json
var tasksJSON []byte
var once sync.Once
var con *connector
type connector struct {
base.Connector
}
type execution struct {
base.ConnectorExecution
}
func Init(bc base.Connector) *connector {
once.Do(func() {
con = &connector{Connector: bc}
err := con.LoadConnectorDefinition(definitionJSON, tasksJSON, nil)
if err != nil {
panic(err)
}
})
return con
}
func (c *connector) CreateExecution(sysVars map[string]any, connection *structpb.Struct, task string) (*base.ExecutionWrapper, error) {
return &base.ExecutionWrapper{Execution: &execution{
ConnectorExecution: base.ConnectorExecution{Connector: c, SystemVariables: sysVars, Connection: connection, Task: task},
}}, nil
}
func (e *execution) Execute(context.Context, []*structpb.Struct) ([]*structpb.Struct, error) {
return nil, fmt.Errorf("the Airbyte connector has been removed")
}
func (c *connector) Test(map[string]any, *structpb.Struct) error {
return fmt.Errorf("the Airbyte connector has been removed")
}