server

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package server hosts the HTTP server for the branch-out application.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateClients

func CreateClients(logger zerolog.Logger, config config.Config) (jira.IClient, trunk.IClient, github.IClient, error)

CreateClients creates the clients for reaching out to external services.

Types

type HealthResponse

type HealthResponse struct {
	Status    string    `json:"status"`
	Timestamp time.Time `json:"timestamp"`
}

HealthResponse represents the health check response

type Option

type Option func(*options)

Option is a functional option that configures the server. Default options are used if no options are provided.

func WithConfig

func WithConfig(cfg config.Config) Option

WithConfig sets the config for the server. Default config is used if no config is provided.

func WithGitHubClient

func WithGitHubClient(client github.IClient) Option

WithGitHubClient sets the GitHub client for the server. This overrides using the config to create a client. Useful for testing.

func WithJiraClient

func WithJiraClient(client jira.IClient) Option

WithJiraClient sets the Jira client for the server. This overrides using the config to create a client. Useful for testing.

func WithLogger

func WithLogger(logger zerolog.Logger) Option

WithLogger sets the logger for the server.

func WithTrunkClient

func WithTrunkClient(client trunk.IClient) Option

WithTrunkClient sets the Trunk client for the server. This overrides using the config to create a client. Useful for testing.

type Server

type Server struct {
	Addr string
	Port int
	// contains filtered or unexported fields
}

Server is the HTTP server for the branch-out application.

func New

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

New creates a new Server.

func (*Server) Error

func (s *Server) Error() error

Error returns the error that occurred during server startup. It is nil if the server started successfully.

func (*Server) Health

func (s *Server) Health() (HealthResponse, error)

Health checks the health of the server and returns health status.

func (*Server) ReceiveWebhook

func (s *Server) ReceiveWebhook(req *http.Request) (*WebhookResponse, error)

ReceiveWebhook processes webhook data and returns the result.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start starts the server and blocks until shutdown. It handles both programmatic shutdown (via context) and OS signals.

func (*Server) Stop

func (s *Server) Stop() error

Stop programmatically stops the server (for testing or programmatic control).

func (*Server) WaitHealthy

func (s *Server) WaitHealthy(ctx context.Context) error

WaitHealthy blocks until the server is healthy or the context is done.

type WebhookResponse

type WebhookResponse struct {
	Success bool   `json:"success"`
	Message string `json:"message"`
	Error   error  `json:"error,omitempty"`
}

WebhookResponse represents the response from webhook processing

Jump to

Keyboard shortcuts

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