apiserver

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 12, 2025 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GitHubWebhookHandler

func GitHubWebhookHandler(opts *githubhandleroptions.HTTPHandler) fasthttp.RequestHandler

GitHubWebhookHandler handles GitHub webhooks.

func HealthCheckHandler

func HealthCheckHandler(ctx *fasthttp.RequestCtx)

HealthCheckHandler handles health check functionality.

func Run

func Run() error

Run runs the server.

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 http handler.

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 kafkaconsumer.KafkaTopicIdentifier) 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 kafkaconsumer.KafkaTopicIdentifier
	KafkaBrokers     []string
	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 api 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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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