eirka-get

command module
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: May 10, 2025 License: MIT Imports: 17 Imported by: 0

README

eirka-get

GoDoc Go Version Build Status

Overview

eirka-get is the read-only API service for the Eirka imageboard system. It serves JSON responses for threads, posts, images, tags, and other imageboard features.

Features

  • Caching System: Efficient Redis caching with circuit breaker pattern for resilience
  • Singleflight Pattern: Prevents thundering herd problems by deduplicating concurrent requests
  • JWT Authentication: Secure authentication for user-specific features
  • Analytics: Request tracking and performance monitoring
  • Efficient Pagination: Paginated results for large data sets

Architecture

The project follows a clean MVC architecture:

  • Controllers: HTTP handlers that process requests and return JSON responses
  • Models: Database interaction layer that fetches data from MySQL
  • Middleware: Request processing components (caching, authentication, analytics)
  • Config: Application configuration management

Cache System

The caching middleware implements Redis caching with several advanced features:

  1. Circuit Breaker Pattern: Automatically detects Redis failures and bypasses cache when Redis is experiencing issues
  2. Cache Key Management: Organizes cache keys by resource type
  3. Singleflight Pattern: Prevents duplicate database queries for concurrent requests to the same resource
  4. Intelligent Caching: Caches only appropriate endpoints and skips dynamic queries

Endpoints

The API provides the following main endpoints:

  • Threads: /thread/:imageboard/:thread/:page
  • Posts: /post/:imageboard/:post
  • Images: /image/:imageboard/:image
  • Tags: /tag/:imageboard/:tag, /tags/:imageboard
  • Search: /tagsearch/:imageboard/:search, /threadsearch/:imageboard/:search
  • Favorites: /favorites/:imageboard, /favorite/:imageboard/:thread, /favorited/:imageboard/:thread
  • Directory: /directory/:imageboard
  • New Content: /new/:imageboard
  • Popular Content: /popular/:imageboard

Installation

# Clone the repository
git clone https://github.com/eirka/eirka-get.git

# Install dependencies
go mod tidy

# Build the application
go build

Testing

# Run all tests
go test ./...

# Run specific tests
go test -v ./middleware -run TestCache

# Run tests with coverage
go test ./... -cover

Contributing

  1. Follow Go standard formatting (gofmt)
  2. Group imports in 3 blocks: standard lib, third-party, project-local
  3. Ensure tests pass before submitting changes
  4. Use error wrapping with SetMeta() to provide context

License

See LICENSE file for details.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
Package config provides configuration for functions
Package config provides configuration for functions
Package controllers provides controllers for handlers
Package controllers provides controllers for handlers
Package middleware provides middleware for Gin
Package middleware provides middleware for Gin
Package models provides models for controllers
Package models provides models for controllers
Package utils provides utilities for handlers
Package utils provides utilities for handlers

Jump to

Keyboard shortcuts

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