-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Mark Sagi-Kazar <[email protected]>
- Loading branch information
1 parent
fe2e970
commit 5a897c1
Showing
19 changed files
with
234 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// Package dedupe implements in-process event deduplication. | ||
package dedupe | ||
|
||
import ( | ||
"github.com/cloudevents/sdk-go/v2/event" | ||
|
||
"github.com/openmeterio/openmeter/internal/dedupe" | ||
) | ||
|
||
// GetEventKey creates a unique key from an event. | ||
func GetEventKey(namespace string, ev event.Event) string { | ||
return dedupe.GetEventKey(namespace, ev) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// Package memorydedupe implements in-memory event deduplication. | ||
package memorydedupe | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/dedupe/memorydedupe" | ||
) | ||
|
||
// Deduplicator implements in-memory event deduplication. | ||
type Deduplicator = memorydedupe.Deduplicator | ||
|
||
// NewDeduplicator returns a new {Deduplicator}. | ||
func NewDeduplicator(size int) (*Deduplicator, error) { | ||
return memorydedupe.NewDeduplicator(size) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Package redisdedupe implements event deduplication using Redis. | ||
package redisdedupe | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/dedupe/redisdedupe" | ||
) | ||
|
||
// Deduplicator implements event deduplication using Redis. | ||
type Deduplicator = redisdedupe.Deduplicator |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ingest | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/ingest" | ||
) | ||
|
||
// Deduplicator checks if an event is unique. | ||
type Deduplicator = ingest.Deduplicator | ||
|
||
// DeduplicatingCollector implements event deduplication at event ingestion. | ||
type DeduplicatingCollector = ingest.DeduplicatingCollector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package httpingest | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/ingest/httpingest" | ||
) | ||
|
||
// Handler receives an event in CloudEvents format and forwards it to a {Collector}. | ||
type Handler = httpingest.Handler | ||
|
||
type HandlerConfig = httpingest.HandlerConfig | ||
|
||
func NewHandler(config HandlerConfig) (*Handler, error) { | ||
return httpingest.NewHandler(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Package ingest implements event ingestion. | ||
package ingest | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/ingest" | ||
) | ||
|
||
// Collector is a receiver of events that handles sending those events to some downstream broker. | ||
type Collector = ingest.Collector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package ingest | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/ingest" | ||
) | ||
|
||
// InMemoryCollector is a {Collector} backed by in-memory storage. | ||
type InMemoryCollector = ingest.InMemoryCollector |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package kafkaingest | ||
|
||
import ( | ||
"context" | ||
"log/slog" | ||
|
||
"github.com/confluentinc/confluent-kafka-go/v2/kafka" | ||
|
||
"github.com/openmeterio/openmeter/internal/ingest/kafkaingest" | ||
) | ||
|
||
// Collector is a receiver of events that handles sending those events to a downstream Kafka broker. | ||
type Collector = kafkaingest.Collector | ||
|
||
func KafkaProducerGroup(ctx context.Context, producer *kafka.Producer, logger *slog.Logger) (execute func() error, interrupt func(error)) { | ||
return kafkaingest.KafkaProducerGroup(ctx, producer, logger) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package kafkaingest | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/ingest/kafkaingest" | ||
) | ||
|
||
// NamespaceHandler is a namespace handler for Kafka ingest topics. | ||
type NamespaceHandler = kafkaingest.NamespaceHandler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package serializer | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/openmeterio/openmeter/internal/ingest/kafkaingest/serializer" | ||
) | ||
|
||
type JSONSerializer = serializer.JSONSerializer | ||
|
||
func NewJSONSerializer() JSONSerializer { | ||
return serializer.NewJSONSerializer() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package serializer | ||
|
||
import ( | ||
_ "embed" | ||
|
||
"github.com/openmeterio/openmeter/internal/ingest/kafkaingest/serializer" | ||
) | ||
|
||
type Serializer = serializer.Serializer | ||
|
||
type CloudEventsKafkaPayload = serializer.CloudEventsKafkaPayload |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package meter | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/meter" | ||
"github.com/openmeterio/openmeter/pkg/models" | ||
) | ||
|
||
// InMemoryRepository is an in-memory meter repository. | ||
type InMemoryRepository = meter.InMemoryRepository | ||
|
||
// NewInMemoryRepository returns a in-memory meter repository. | ||
func NewInMemoryRepository(meters []models.Meter) *InMemoryRepository { | ||
return meter.NewInMemoryRepository(meters) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package meter | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/meter" | ||
) | ||
|
||
// Repository is an interface to the meter store. | ||
type Repository = meter.Repository |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Package namespace adds a concept of tenancy to OpenMeter allowing to segment clients. | ||
package namespace | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/namespace" | ||
) | ||
|
||
// Manager is responsible for managing namespaces in different components. | ||
type Manager = namespace.Manager | ||
|
||
type ManagerConfig = namespace.ManagerConfig | ||
|
||
func NewManager(config ManagerConfig) (*Manager, error) { | ||
return namespace.NewManager(config) | ||
} | ||
|
||
// Handler is responsible for creating a namespace in a given component. | ||
// | ||
// An empty name means a default namespace is supposed to be created. | ||
// The concept of a default namespace is implementation specific. | ||
// | ||
// The behavior for trying to create a namespace that already exists is unspecified at the moment. | ||
type Handler = namespace.Handler |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package router | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/server/router" | ||
) | ||
|
||
type IngestHandler = router.IngestHandler | ||
|
||
type Config = router.Config | ||
|
||
type Router = router.Router | ||
|
||
func NewRouter(config Config) (*Router, error) { | ||
return router.NewRouter(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package server | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/server" | ||
) | ||
|
||
type Server = server.Server | ||
|
||
type Config = server.Config | ||
|
||
func NewServer(config *Config) (*Server, error) { | ||
return server.NewServer(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package clickhouse_connector | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/streaming/clickhouse_connector" | ||
) | ||
|
||
// ClickhouseConnector implements `ingest.Connector“ and `namespace.Handler interfaces. | ||
type ClickhouseConnector = clickhouse_connector.ClickhouseConnector | ||
|
||
type ClickhouseConnectorConfig = clickhouse_connector.ClickhouseConnectorConfig | ||
|
||
func NewClickhouseConnector(config ClickhouseConnectorConfig) (*ClickhouseConnector, error) { | ||
return clickhouse_connector.NewClickhouseConnector(config) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package clickhouse_connector | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/streaming/clickhouse_connector" | ||
) | ||
|
||
type MeterView = clickhouse_connector.MeterView |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package streaming | ||
|
||
import ( | ||
"github.com/openmeterio/openmeter/internal/streaming" | ||
) | ||
|
||
type ListEventsParams = streaming.ListEventsParams | ||
|
||
type QueryParams = streaming.QueryParams | ||
|
||
type QueryResult = streaming.QueryResult | ||
|
||
type Connector = streaming.Connector |