server

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package server 提供 Steam 服务器(A2S 协议)相关查询服务 包含单个/批量服务器基础信息、玩家信息、规则信息的查询能力, 支持限流、重试、超时控制,保证线程安全, 底层基于 go-a2s 库实现 Package server provides query services related to Steam servers (A2S protocol) It includes the ability to query single/batch server basic info, player info, rule info, supports rate limiting, retry, timeout control, ensures thread safety, and is implemented based on the go-a2s library at the bottom

Package server 提供Steam服务器信息查询相关服务 包含单个/批量服务器基础信息、玩家信息、规则信息的查询能力, 支持限流、重试、超时控制, 保证线程安全 Package server provides services for querying Steam server information It includes the ability to query single/batch server basic info, player info, rule info, supports rate limiting, retry, timeout control, and ensures thread safety

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ServerService

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

ServerService Steam服务器查询服务核心结构体 封装所有A2S协议相关的服务器信息查询方法,通过内部client管理底层通信 ServerService is the core structure of Steam server query service Encapsulates all A2S protocol-related server information query methods, and manages underlying communication through internal client

func NewServerService

func NewServerService(c *client.Client) *ServerService

NewServerService 创建ServerService实例 NewServerService creates a ServerService instance Initializes the server query service, relying on the internal client to provide underlying communication capabilities

func (*ServerService) GetServerDetail

func (s *ServerService) GetServerDetail(addr string) (models.SteamServerResponse, error)

GetServerDetail 聚合获取单个服务器的完整信息(基础信息+玩家+规则) 内部调用QueryServerInfo/QueryServerPlayers/QueryServerRules三个独立方法, 非核心接口(玩家/规则)失败仅记录错误, 核心接口(基础信息)失败直接返回 参数:

  • addr: 服务器地址, 格式为"ip:port"

返回值:

  • models.SteamServerResponse: 聚合后的服务器完整数据
  • error: 错误信息(任意子接口失败会返回错误, 但已获取的数据会保留)

GetServerDetail aggregately gets the complete information of a single server (basic info + players + rules) Internally calls three independent methods: QueryServerInfo/QueryServerPlayers/QueryServerRules, non-core interfaces (players/rules) only record errors when failed, core interface (basic info) returns directly when failed Parameters:

  • addr: Server address in the format of "ip:port"

Return values:

  • models.SteamServerResponse: Aggregated complete server data
  • error: Error information (any sub-interface failure will return an error, but the obtained data will be retained)

func (*ServerService) GetServerDetailList

func (s *ServerService) GetServerDetailList(
	addrs []string,
	qps float64,
	burst int,
	timeout time.Duration,
	retry int,
) ([]models.SteamServerResponse, []error, error)

GetServerDetailList 批量查询多个服务器的完整聚合信息(带限流、重试、超时) 内部调用GetServerDetail聚合接口, 采用并发方式查询, 保证结果顺序与输入地址列表一致 支持指数退避重试策略, 线程安全的结果写入机制 参数:

  • addrs: 服务器地址列表, 格式为["ip:port", ...]
  • qps: 每秒最大请求数(限流)
  • burst: 突发请求上限(限流)
  • timeout: 整体超时时间
  • retry: 单个请求重试次数

返回值:

  • []models.SteamServerResponse: 批量聚合结果(与输入地址一一对应)
  • []error: 每个地址对应的错误信息
  • error: 全局错误(如上下文超时、限流失效)

GetServerDetailList batch queries the complete aggregated information of multiple servers (with rate limit, retry, timeout) Internally calls the GetServerDetail aggregation interface, uses concurrent query method to ensure the result order is consistent with the input address list Supports exponential backoff retry strategy and thread-safe result writing mechanism Parameters:

  • addrs: Server address list in the format of ["ip:port", ...]
  • qps: Maximum requests per second (rate limit)
  • burst: Maximum burst requests (rate limit)
  • timeout: Overall timeout time
  • retry: Number of retries for a single request

Return values:

  • []models.SteamServerResponse: Batch aggregation results (one-to-one correspondence with input addresses)
  • []error: Error information corresponding to each address
  • error: Global error (such as context timeout, rate limit failure)

func (*ServerService) QueryServerInfo

func (s *ServerService) QueryServerInfo(addr string) (a2s.ServerInfo, error)

QueryServerInfo 查询单个服务器的基础信息(A2S_Info接口) 每个请求独立创建A2S Client, 避免并发资源竞争, 保证线程安全 参数:

  • addr: 服务器地址, 格式为"ip:port"

返回值:

  • a2s.ServerInfo: 服务器基础信息结构体
  • error: 错误信息, 包含Client创建失败/接口调用失败等场景

QueryServerInfo queries the basic information of a single server (A2S_Info interface) Each request creates an independent A2S Client to avoid concurrent resource competition and ensure thread safety Parameters:

  • addr: Server address in the format of "ip:port"

Return values:

  • a2s.ServerInfo: Server basic information structure
  • error: Error information, including Client creation failure/interface call failure and other scenarios

func (*ServerService) QueryServerInfoList

func (s *ServerService) QueryServerInfoList(
	addrs []string,
	qps float64,
	burst int,
	timeout time.Duration,
	retry int,
) ([]a2s.ServerInfo, []error, error)

QueryServerInfoList 批量查询多个服务器的基础信息(带限流、重试、超时) 采用并发方式查询, 保证结果顺序与输入地址列表一致, 支持指数退避重试策略 参数:

  • addrs: 服务器地址列表, 格式为["ip:port", ...]
  • qps: 每秒最大请求数(限流)
  • burst: 突发请求上限(限流)
  • timeout: 整体超时时间
  • retry: 单个请求重试次数

返回值:

  • []a2s.ServerInfo: 批量查询结果(与输入地址列表一一对应)
  • []error: 每个地址对应的错误信息(nil表示成功)
  • error: 全局错误(如上下文超时、限流失效)

QueryServerInfoList batch queries the basic information of multiple servers (with rate limit, retry, timeout) Uses concurrent query method to ensure the result order is consistent with the input address list, supports exponential backoff retry strategy Parameters:

  • addrs: Server address list in the format of ["ip:port", ...]
  • qps: Maximum requests per second (rate limit)
  • burst: Maximum burst requests (rate limit)
  • timeout: Overall timeout time
  • retry: Number of retries for a single request

Return values:

  • []a2s.ServerInfo: Batch query results (one-to-one correspondence with input address list)
  • []error: Error information corresponding to each address (nil means success)
  • error: Global error (such as context timeout, rate limit failure)

func (*ServerService) QueryServerPlayers

func (s *ServerService) QueryServerPlayers(addr string) (a2s.PlayerInfo, error)

QueryServerPlayers 查询单个服务器的玩家信息(A2S_Player接口) 每个请求独立创建A2S Client, 避免并发资源竞争, 保证线程安全 参数:

  • addr: 服务器地址, 格式为"ip:port"

返回值:

  • a2s.PlayerInfo: 服务器玩家信息结构体
  • error: 错误信息, 包含Client创建失败/接口调用失败等场景

QueryServerPlayers queries the player information of a single server (A2S_Player interface) Each request creates an independent A2S Client to avoid concurrent resource competition and ensure thread safety Parameters:

  • addr: Server address in the format of "ip:port"

Return values:

  • a2s.PlayerInfo: Server player information structure
  • error: Error information, including Client creation failure/interface call failure and other scenarios

func (*ServerService) QueryServerPlayersList

func (s *ServerService) QueryServerPlayersList(
	addrs []string,
	qps float64,
	burst int,
	timeout time.Duration,
	retry int,
) ([]a2s.PlayerInfo, []error, error)

QueryServerPlayersList 批量查询多个服务器的玩家信息(带限流、重试、超时) 采用并发方式查询, 保证结果顺序与输入地址列表一致, 支持指数退避重试策略 参数/返回值格式与QueryServerInfoList完全一致 QueryServerPlayersList batch queries the player information of multiple servers (with rate limit, retry, timeout) Uses concurrent query method to ensure the result order is consistent with the input address list, supports exponential backoff retry strategy Parameter/return value format is exactly the same as QueryServerInfoList

func (*ServerService) QueryServerRules

func (s *ServerService) QueryServerRules(addr string) (a2s.RulesInfo, error)

QueryServerRules 查询单个服务器的规则信息(A2S_Rules接口) 每个请求独立创建A2S Client, 避免并发资源竞争, 保证线程安全 参数:

  • addr: 服务器地址, 格式为"ip:port"

返回值:

  • a2s.RulesInfo: 服务器规则信息结构体
  • error: 错误信息, 包含Client创建失败/接口调用失败等场景

QueryServerRules queries the rule information of a single server (A2S_Rules interface) Each request creates an independent A2S Client to avoid concurrent resource competition and ensure thread safety Parameters:

  • addr: Server address in the format of "ip:port"

Return values:

  • a2s.RulesInfo: Server rule information structure
  • error: Error information, including Client creation failure/interface call failure and other scenarios

func (*ServerService) QueryServerRulesList

func (s *ServerService) QueryServerRulesList(
	addrs []string,
	qps float64,
	burst int,
	timeout time.Duration,
	retry int,
) ([]a2s.RulesInfo, []error, error)

QueryServerRulesList 批量查询多个服务器的规则信息(带限流、重试、超时) 采用并发方式查询, 保证结果顺序与输入地址列表一致, 支持指数退避重试策略 参数/返回值格式与QueryServerInfoList完全一致 QueryServerRulesList batch queries the rule information of multiple servers (with rate limit, retry, timeout) Uses concurrent query method to ensure the result order is consistent with the input address list, supports exponential backoff retry strategy Parameter/return value format is exactly the same as QueryServerInfoList

Jump to

Keyboard shortcuts

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