-
Notifications
You must be signed in to change notification settings - Fork 4
/
unimplemented.go
130 lines (101 loc) · 4.41 KB
/
unimplemented.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Copyright © 2022 Meroxa, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package sdk
import (
"context"
"fmt"
"github.com/conduitio/conduit-commons/config"
"github.com/conduitio/conduit-commons/opencdc"
)
// UnimplementedDestination should be embedded to have forward compatible implementations.
type UnimplementedDestination struct{}
// Config needs to be overridden in the actual implementation.
func (UnimplementedDestination) Config() DestinationConfig {
panic("it is required to implement Config")
}
// Open needs to be overridden in the actual implementation.
func (UnimplementedDestination) Open(context.Context) error {
return fmt.Errorf("action \"Open\": %w", ErrUnimplemented)
}
// Write needs to be overridden in the actual implementation.
func (UnimplementedDestination) Write(context.Context, []opencdc.Record) (int, error) {
return 0, fmt.Errorf("action \"Write\": %w", ErrUnimplemented)
}
// Teardown needs to be overridden in the actual implementation.
func (UnimplementedDestination) Teardown(context.Context) error {
return fmt.Errorf("action \"Teardown\": %w", ErrUnimplemented)
}
// LifecycleOnCreated won't do anything by default.
func (UnimplementedDestination) LifecycleOnCreated(context.Context, config.Config) error {
return nil
}
// LifecycleOnUpdated won't do anything by default.
func (UnimplementedDestination) LifecycleOnUpdated(context.Context, config.Config, config.Config) error {
return nil
}
// LifecycleOnDeleted won't do anything by default.
func (UnimplementedDestination) LifecycleOnDeleted(context.Context, config.Config) error {
return nil
}
func (UnimplementedDestination) mustEmbedUnimplementedDestination() {}
type UnimplementedDestinationConfig struct{}
func (UnimplementedDestinationConfig) mustEmbedUnimplementedDestinationConfig() {}
func (UnimplementedDestinationConfig) Validate(context.Context) error {
return nil
}
// UnimplementedSource should be embedded to have forward compatible implementations.
type UnimplementedSource struct{}
// Config needs to be overridden in the actual implementation.
func (UnimplementedSource) Config() SourceConfig {
panic("it is required to implement Config")
}
// Open needs to be overridden in the actual implementation.
func (UnimplementedSource) Open(context.Context, opencdc.Position) error {
return fmt.Errorf("action \"Open\": %w", ErrUnimplemented)
}
// Read needs to be overridden in the actual implementation.
func (UnimplementedSource) Read(context.Context) (opencdc.Record, error) {
return opencdc.Record{}, fmt.Errorf("action \"Read\": %w", ErrUnimplemented)
}
// ReadN can be overridden. If it's not implemented, Read will be used as a fallback.
func (s UnimplementedSource) ReadN(context.Context, int) ([]opencdc.Record, error) {
return nil, fmt.Errorf("action \"ReadN\": %w", ErrUnimplemented)
}
// Ack should be overridden if acks need to be forwarded to the source,
// otherwise it is optional.
func (UnimplementedSource) Ack(context.Context, opencdc.Position) error {
return fmt.Errorf("action \"Ack\": %w", ErrUnimplemented)
}
// Teardown needs to be overridden in the actual implementation.
func (UnimplementedSource) Teardown(context.Context) error {
return fmt.Errorf("action \"Teardown\": %w", ErrUnimplemented)
}
// LifecycleOnCreated won't do anything by default.
func (UnimplementedSource) LifecycleOnCreated(context.Context, config.Config) error {
return nil
}
// LifecycleOnUpdated won't do anything by default.
func (UnimplementedSource) LifecycleOnUpdated(context.Context, config.Config, config.Config) error {
return nil
}
// LifecycleOnDeleted won't do anything by default.
func (UnimplementedSource) LifecycleOnDeleted(context.Context, config.Config) error {
return nil
}
func (UnimplementedSource) mustEmbedUnimplementedSource() {}
type UnimplementedSourceConfig struct{}
func (UnimplementedSourceConfig) mustEmbedUnimplementedSourceConfig() {}
func (UnimplementedSourceConfig) Validate(context.Context) error {
return nil
}