handler

package
v0.3.6 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var PluginName = "handler"

Functions

func Plugin added in v0.3.6

func Plugin(ctx context.Context, client *wkafka.Client, config interface{}) error

func PluginWithName added in v0.3.6

func PluginWithName() (string, wkafka.PluginFunc)

Types

type Config added in v0.3.6

type Config struct {
	Enabled    bool          `cfg:"enabled"     json:"enabled"`
	Addr       string        `cfg:"addr"        json:"addr"`
	PathPrefix string        `cfg:"path_prefix" json:"path_prefix"`
	PubSub     *PubSubConfig `cfg:"pubsub"      json:"pubsub"`
}

type DLQRecord added in v0.3.5

type DLQRecord struct {
	Topic     string   `json:"topic"`
	Partition int32    `json:"partition"`
	Offset    int64    `json:"offset"`
	Key       []byte   `json:"key"`
	Value     []byte   `json:"value"`
	Timestamp string   `json:"timestamp"`
	Headers   []Header `json:"headers"`
}

type Error added in v0.3.5

type Error struct {
	Msg  string
	Err  error
	Code int
}

func NewError added in v0.3.5

func NewError(message string, err error, code int) Error

func (Error) Error added in v0.3.5

func (e Error) Error() string

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

@Title wkafka API @BasePath /wkafka/ @description Kafka library

func New

func New(client *wkafka.Client, opts ...Option) (*Handler, error)

NewHandler returns a http.Handler implementation.

func (*Handler) Event added in v0.3.5

func (h *Handler) Event(w http.ResponseWriter, r *http.Request)

func (*Handler) File added in v0.3.6

func (h *Handler) File() (http.Handler, error)

func (*Handler) Handler added in v0.3.5

func (h *Handler) Handler() (string, http.Handler)

func (*Handler) Info added in v0.3.4

func (h *Handler) Info(w http.ResponseWriter, _ *http.Request)

Info returns the current information of the client. @Summary Get the current information of the client. @Tags wkafka @Success 200 {object} InfoResponse @Router /v1/info [GET]

func (*Handler) Serve added in v0.3.6

func (h *Handler) Serve(ctx context.Context) error

func (*Handler) ServeHTTP added in v0.3.5

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Handler) SkipDLQ added in v0.3.6

func (h *Handler) SkipDLQ(w http.ResponseWriter, r *http.Request)

@Summary Skip on DLQ topic. @Tags wkafka @Accept json @Produce json @Param skip body SkipDLQRequest true "skip" @Success 200 {object} Response @Router /v1/skip-dlq [PATCH]

func (*Handler) SkipSet added in v0.3.5

func (h *Handler) SkipSet(w http.ResponseWriter, r *http.Request)

@Summary Set the skip. @Tags wkafka @Accept json @Produce json @Param skip body SkipRequest true "skip" @Success 200 {object} Response @Router /v1/skip [PUT]

func (*Handler) SkipUpdate added in v0.3.5

func (h *Handler) SkipUpdate(w http.ResponseWriter, r *http.Request)

@Summary Patch the skip. @Tags wkafka @Accept json @Produce json @Param skip body SkipRequest true "skip" @Success 200 {object} Response @Router /v1/skip [PATCH]

func (*Handler) StartPubSub added in v0.3.6

func (h *Handler) StartPubSub(ctx context.Context) error

func (*Handler) TriggerInfo added in v0.3.5

func (h *Handler) TriggerInfo()

func (*Handler) UI added in v0.3.5

func (h *Handler) UI() (http.Handler, error)
type Header struct {
	Key   string `json:"key"`
	Value []byte `json:"value"`
}

type InfoResponse added in v0.3.5

type InfoResponse struct {
	DLQTopics []string       `json:"dlq_topics"`
	Topics    []string       `json:"topics"`
	Skip      wkafka.SkipMap `json:"skip"`
	DLQRecord *DLQRecord     `json:"dlq_record"`
}

type Option added in v0.3.2

type Option func(*option)

func WithAddr added in v0.3.6

func WithAddr(addr string) Option

WithAddr to set address for handler.

  • Only for Serve method, default is ":17070".

func WithPathPrefix added in v0.3.5

func WithPathPrefix(prefix string) Option

WithPathPrefix to set prefix path for handler.

func WithPubSub added in v0.3.6

func WithPubSub(cfg *PubSubConfig) Option

WithPubSub to set pubsub configuration.

type PubSubConfig added in v0.3.6

type PubSubConfig struct {
	Prefix string `cfg:"prefix" json:"prefix"`

	Redis *RedisConfig `cfg:"redis" json:"redis"`
}

func (*PubSubConfig) New added in v0.3.6

func (c *PubSubConfig) New(groupID string, logger wkafka.Logger) (pubsub, error)

type PubSubModel added in v0.3.6

type PubSubModel struct {
	Type  string          `json:"type"`
	Value json.RawMessage `json:"value"`
}

type PubSubModelPublish added in v0.3.6

type PubSubModelPublish struct {
	Type  string      `json:"type"`
	Value interface{} `json:"value"`
}

type Redis added in v0.3.6

type Redis struct {
	// contains filtered or unexported fields
}

func (*Redis) Close added in v0.3.6

func (r *Redis) Close() error

func (*Redis) GetTopic added in v0.3.6

func (r *Redis) GetTopic() string

func (*Redis) Publish added in v0.3.6

func (r *Redis) Publish(ctx context.Context, data PubSubModelPublish) error

func (*Redis) Subscribe added in v0.3.6

func (r *Redis) Subscribe(ctx context.Context, handler func(PubSubModel) error) error

type RedisConfig added in v0.3.6

type RedisConfig struct {
	Address  string           `cfg:"address"  json:"address"`
	Username string           `cfg:"username" json:"username"`
	Password string           `cfg:"password" json:"password"`
	TLS      wkafka.TLSConfig `cfg:"tls"      json:"tls"`
}

type RegexCacheStore added in v0.3.5

type RegexCacheStore struct {
	Regex        string `cfg:"regex"`
	CacheControl string `cfg:"cache_control"`
	// contains filtered or unexported fields
}

type RegexPathStore added in v0.3.5

type RegexPathStore struct {
	Regex       string `cfg:"regex"`
	Replacement string `cfg:"replacement"`
	// contains filtered or unexported fields
}

type Response added in v0.3.5

type Response struct {
	Message string `json:"message"`
}

type SkipDLQRequest added in v0.3.6

type SkipDLQRequest map[int32]wkafka.OffsetConfig

type SkipRequest added in v0.3.5

type SkipRequest map[string]map[int32]wkafka.OffsetConfig

Jump to

Keyboard shortcuts

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