Documentation
¶
Overview ¶
Package api manages the server setup and its dependencies like database, cache, and logging.
Index ¶
- type Server
- func (s *Server) Cleanup() error
- func (s *Server) InitClient(ctx context.Context) error
- func (s *Server) InitKafkaClient() error
- func (s *Server) InitLogger() error
- func (s *Server) InitMinioClient(ctx context.Context) error
- func (s *Server) InitRedisClient(ctx context.Context) error
- func (s *Server) InitSessionStore() error
- func (s *Server) LoadRSAKeys() error
- func (s *Server) Ready() bool
- func (s *Server) RegisterGobTypes()
- func (s *Server) Shutdown() error
- func (s *Server) Start() error
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 ¶
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) InitClient ¶
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 (*Server) InitLogger ¶
InitLogger initializes the logger based on the configuration.
func (*Server) InitMinioClient ¶
InitMinioClient initializes the Minio client with the specified configuration.
func (*Server) InitRedisClient ¶
InitRedisClient creates and verifies a Redis client connection.
func (*Server) InitSessionStore ¶
InitSessionStore initializes the session store with Redis backend based on server's configuration.
func (*Server) LoadRSAKeys ¶
func (*Server) RegisterGobTypes ¶
func (s *Server) RegisterGobTypes()
RegisterGobTypes registers necessary types with the gob package for session management, such as UUIDs.