webhookserver

package
v0.1.7 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	ServerDefaultReadTimeout  = 5 * time.Second
	ServerDefaultWriteTimeout = 10 * time.Second
	ServerDefaultIdleTimeout  = 15 * time.Second
	ServerDefaultListenAddr   = ":8000"
)

default values.

Variables

View Source
var ServerVersion string

ServerVersion holds webhookserver release version.

Functions

This section is empty.

Types

type HTTPServer

type HTTPServer interface {
	Start() error
	Stop() error
}

HTTPServer defines the basic operations for managing an HTTP server's lifecycle.

type MethodHandler

type MethodHandler map[string]fasthttp.RequestHandler

MethodHandler holds http method and http handler function information.

type Option

type Option func(*Server) error

Option represents option function type.

func WithHTTPHandler

func WithHTTPHandler(method, path string, handler fasthttp.RequestHandler) Option

WithHTTPHandler adds given http handler to handler stack.

func WithIdleTimeout

func WithIdleTimeout(d time.Duration) Option

WithIdleTimeout sets idle timeout.

func WithKafkaBrokers

func WithKafkaBrokers(brokers string) Option

WithKafkaBrokers sets kafka brokers list.

func WithKafkaGitHubTopic

func WithKafkaGitHubTopic(s string) Option

WithKafkaGitHubTopic sets kafka topic name for github webhooks.

func WithListenAddr

func WithListenAddr(addr string) Option

WithListenAddr sets listen addr.

func WithLogger

func WithLogger(l *slog.Logger) Option

WithLogger sets logger.

func WithReadTimeout

func WithReadTimeout(d time.Duration) Option

WithReadTimeout sets read timeout.

func WithWriteTimeout

func WithWriteTimeout(d time.Duration) Option

WithWriteTimeout sets write timeout.

type Server

type Server struct {
	Logger           *slog.Logger
	FastHTTP         *fasthttp.Server
	Handlers         map[string]MethodHandler
	ListenAddr       string
	KafkaGitHubTopic kafkacp.KafkaTopicIdentifier
	KafkaBrokers     kafkacp.KafkaBrokers
	ReadTimeout      time.Duration
	WriteTimeout     time.Duration
	IdleTimeout      time.Duration
}

Server represents server configuration. Must implements HTTPServer interface.

func New

func New(options ...Option) (*Server, error)

New instantiates new webhookserver server.

func (*Server) Start

func (s *Server) Start() error

Start starts the fast http server.

func (*Server) Stop

func (s *Server) Stop() error

Stop stops the fast http server.

Jump to

Keyboard shortcuts

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