Skip to content

Commit

Permalink
Merged namingstrategy packages
Browse files Browse the repository at this point in the history
  • Loading branch information
noctarius committed Jul 22, 2023
1 parent 4037761 commit 08e3738
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion internal/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
"github.com/urfave/cli"

// Register built-in naming strategies
_ "github.com/noctarius/timescaledb-event-streamer/internal/eventing/namingstrategies"
_ "github.com/noctarius/timescaledb-event-streamer/spi/namingstrategy"

// Register built-in sinks
_ "github.com/noctarius/timescaledb-event-streamer/internal/eventing/sinks/awskinesis"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,34 +15,33 @@
* limitations under the License.
*/

package namingstrategies
package namingstrategy

import (
"fmt"
"github.com/noctarius/timescaledb-event-streamer/spi/config"
"github.com/noctarius/timescaledb-event-streamer/spi/namingstrategy"
"github.com/noctarius/timescaledb-event-streamer/spi/schema"
)

func init() {
namingstrategy.RegisterNamingStrategy(config.Debezium,
func(_ *config.Config) (namingstrategy.NamingStrategy, error) {
return &DebeziumNamingStrategy{}, nil
RegisterNamingStrategy(config.Debezium,
func(_ *config.Config) (NamingStrategy, error) {
return &debeziumNamingStrategy{}, nil
},
)
}

type DebeziumNamingStrategy struct {
type debeziumNamingStrategy struct {
}

func (d *DebeziumNamingStrategy) EventTopicName(topicPrefix string, hypertable schema.TableAlike) string {
func (d *debeziumNamingStrategy) EventTopicName(topicPrefix string, hypertable schema.TableAlike) string {
return fmt.Sprintf("%s.%s.%s", topicPrefix, hypertable.SchemaName(), hypertable.TableName())
}

func (d *DebeziumNamingStrategy) SchemaTopicName(topicPrefix string, hypertable schema.TableAlike) string {
func (d *debeziumNamingStrategy) SchemaTopicName(topicPrefix string, hypertable schema.TableAlike) string {
return fmt.Sprintf("%s.%s.%s", topicPrefix, hypertable.SchemaName(), hypertable.TableName())
}

func (d *DebeziumNamingStrategy) MessageTopicName(topicPrefix string) string {
func (d *debeziumNamingStrategy) MessageTopicName(topicPrefix string) string {
return fmt.Sprintf("%s.message", topicPrefix)
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

package namingstrategies
package namingstrategy

import (
"github.com/noctarius/timescaledb-event-streamer/spi/pgtypes"
Expand All @@ -28,7 +28,7 @@ func TestDebeziumNamingStrategy_EventTopicName(t *testing.T) {
topicPrefix := "foobar"
hypertable := systemcatalog.NewHypertable(1, "test", "schema", "hypertable", "", "", nil, 0, false, nil, nil, pgtypes.DEFAULT)

strategy := DebeziumNamingStrategy{}
strategy := debeziumNamingStrategy{}
topicName := strategy.EventTopicName(topicPrefix, hypertable)
assert.Equal(t, "foobar.schema.hypertable", topicName)
}
Expand All @@ -37,7 +37,7 @@ func TestDebeziumNamingStrategy_SchemaTopicName(t *testing.T) {
topicPrefix := "foobar"
hypertable := systemcatalog.NewHypertable(1, "test", "schema", "hypertable", "", "", nil, 0, false, nil, nil, pgtypes.DEFAULT)

strategy := DebeziumNamingStrategy{}
strategy := debeziumNamingStrategy{}
topicName := strategy.SchemaTopicName(topicPrefix, hypertable)
assert.Equal(t, "foobar.schema.hypertable", topicName)
}

0 comments on commit 08e3738

Please sign in to comment.