kbridge

package module
v0.0.0-...-ad3276f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

README

kbridge

HTTP/gRPC bridge to Apache Kafka topics

Features

  • Configurable endpoints, either REST or otherwise. YAML configuration:
server:
  host: 0.0.0.0
  port: 3000

kafka:
  kafkaUrl: "kafka.local.cluster:9094"

endpoints:
- url: "/products/:prodId"
  method: "GET"
  topic: "products"
  reply-topic: "products-response"
- url: "/products"
  method: "POST"
  topic: "products-get"
  • Configuration by endpoint

  • URL path templates with Go Gin

  • Support for path variables

  • Support for query parameters

  • gRPC support

  • custom protobuf schemas (?)

Documentation

Index

Constants

View Source
const AppName string = "kbridge"

Variables

View Source
var ConfigJSONSchema string

Functions

This section is empty.

Types

type Config

type Config struct {
	Version   string                `json:"version" yaml:"version" mapstructure:"version"`
	Server    *ServerConfig         `json:"server" yaml:"server" mapstructure:"server"`
	Kafka     *KafkaConfig          `json:"kafka" yaml:"kafka" mapstructure:"kafka"`
	Endpoints []*EndpointDefinition `json:"endpoints" yaml:"endpoints" mapstructure:"endpoints"`
}

func LoadConfig

func LoadConfig() (*Config, error)

func LoadConfigFromFile

func LoadConfigFromFile(configFile string) (*Config, error)

func (*Config) Validate

func (c *Config) Validate() error

type EndpointDefinition

type EndpointDefinition struct {
	IsGRPC      bool                 `json:"grpc" yaml:"grpc" mapstructure:"grpc"`
	Path        string               `json:"path" yaml:"path" mapstructure:"path"`
	HTTPMethod  string               `json:"method" yaml:"method" mapstructure:"method"`
	DataType    string               `json:"dataType" yaml:"dataType" mapstructure:"dataType"`
	Passthrough bool                 `json:"passthrough" yaml:"passthrough" mapstructure:"passthrough"`
	Kafka       *EndpointKafkaConfig `json:"kafka" yaml:"kafka" mapstructure:"kafka"`
}

type EndpointKafkaConfig

type EndpointKafkaConfig struct {
	Topic          string `json:"topic" yaml:"topic" mapstructure:"topic"`
	Partition      int    `json:"partition" yaml:"partition" mapstructure:"partition"`
	ReplyTopic     string `json:"replyTopic" yaml:"replyTopic" mapstructure:"replyTopic"`
	ReplyPartition int    `json:"replyPartition" yaml:"replyPartition" mapstructure:"replyPartition"`
}

type HTTPConfig

type HTTPConfig struct {
	Host string `json:"host" yaml:"host" mapstructure:"host"`
	Port int    `json:"port" yaml:"port" mapstructure:"port"`
}

type KafkaConfig

type KafkaConfig struct {
	KafkaURL     string `json:"kafkaUrl" yaml:"kafkaUrl" mapstructure:"kafkaUrl"`
	BatchSize    int    `json:"batchSize" yaml:"batchSize" mapstructure:"batchSize"`
	BatchTimeout int    `json:"batchTimeout" yaml:"batchTimeout" mapstructure:"batchTimeout"`
}

type ServerConfig

type ServerConfig struct {
	HTTPConfig *HTTPConfig `json:"http" yaml:"http" mapstructure:"http"`
}

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL