api

package
v0.0.0-...-3a43694 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package api manages the server setup and its dependencies like database, cache, and logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	Config  config.Server
	Client  *ent.Client
	Fiber   *fiber.App
	Logger  *zerolog.Logger
	Session *session.Store
	Kafka   *kfk.Client
	Redis   *rop.Client
	Minio   *minio.Client
}

Server represents the main server instance containing all essential components such as configuration, database, web server, logger, session store, Kafka, Redis, and Minio clients.

func NewServer

func NewServer(cfg config.Server) *Server

NewServer initializes a new Server with the specified configuration. It returns a pointer to the Server instance.

Parameters:

cfg config.Server: Configuration settings for the server.

Returns:

*Server: Pointer to the newly created Server instance.

func (*Server) Cleanup

func (s *Server) Cleanup() error

Cleanup closes all connections and cleans up resources.

func (*Server) InitClient

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

InitClient establishes a database connection using the provided configuration and verifies it by pinging the database.

Parameters:

ctx context.Context: Context for cancellation and deadlines.

Returns:

error: Error if the database connection or ping fails, nil otherwise.

func (*Server) InitKafkaClient

func (s *Server) InitKafkaClient() error

func (*Server) InitLogger

func (s *Server) InitLogger() error

InitLogger initializes the logger based on the configuration.

func (*Server) InitMinioClient

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

InitMinioClient initializes the Minio client with the specified configuration.

func (*Server) InitRedisClient

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

InitRedisClient creates and verifies a Redis client connection.

func (*Server) InitSessionStore

func (s *Server) InitSessionStore() error

InitSessionStore initializes the session store with Redis backend based on server's configuration.

func (*Server) LoadRSAKeys

func (s *Server) LoadRSAKeys() error

func (*Server) Ready

func (s *Server) Ready() bool

Ready checks if all critical components of the server are initialized.

func (*Server) RegisterGobTypes

func (s *Server) RegisterGobTypes()

RegisterGobTypes registers necessary types with the gob package for session management, such as UUIDs.

func (*Server) Shutdown

func (s *Server) Shutdown() error

Shutdown performs a graceful shutdown of all server components.

func (*Server) Start

func (s *Server) Start() error

Start runs the server if all components are ready and registers necessary types.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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