server

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is the Nimbus Captcha Solver API Backend Service.

func NewServer

func NewServer(cfg *ServerConfig) *Server

NewServer initializes a new Captcha Server instance.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the listening network address.

func (*Server) Shutdown

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

Shutdown stops the server gracefully.

func (*Server) Start

func (s *Server) Start() error

Start launches the HTTP server listening on the configured address.

type ServerConfig

type ServerConfig struct {
	Addr       string
	APIKeys    map[string]float64 // Map of valid clientKey -> balance credit
	MaxWorkers int
}

ServerConfig holds configuration parameters for the Captcha Backend Server.

type TaskItem

type TaskItem struct {
	ID        string
	Payload   captcha.TaskPayload
	Status    string // "processing", "ready", "failed"
	Solution  captcha.Solution
	ErrorMsg  string
	CreatedAt time.Time
	UpdatedAt time.Time
}

TaskItem represents an active or completed captcha solving job in memory.

type TaskQueue

type TaskQueue struct {
	// contains filtered or unexported fields
}

TaskQueue is a thread-safe, in-memory queue for task management and retrieval.

func NewTaskQueue

func NewTaskQueue(ttl time.Duration) *TaskQueue

NewTaskQueue initializes a task queue.

func (*TaskQueue) Add

func (q *TaskQueue) Add(id string, payload captcha.TaskPayload) *TaskItem

Add enqueues a new task.

func (*TaskQueue) Complete

func (q *TaskQueue) Complete(id string, sol captcha.Solution) error

Complete marks a task as successfully solved.

func (*TaskQueue) Fail

func (q *TaskQueue) Fail(id string, errMsg string) error

Fail marks a task as failed.

func (*TaskQueue) Get

func (q *TaskQueue) Get(id string) (*TaskItem, bool)

Get retrieves a task by ID.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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