接口参考
本文档由脚本自动生成,请勿手动编辑
本文档按包列出 Kuiper 框架中的全部 128 个公共接口及其自身声明的方法签名(不含继承自父接口的方法)。
依赖注入
ContainerBuilderAwareInterface
命名空间: kuiper\di
方法
setContainerBuilder()
void setContainerBuilder(kuiper\di\ContainerBuilderInterface $containerBuilder)Sets the container builder.
ContainerBuilderInterface
命名空间: kuiper\di
方法
addBeanAwareInjection()
self addBeanAwareInjection(kuiper\di\BeanAwareInjection $injection)hasDefinition()
bool hasDefinition(string $name)是否已经注册了指定名称的 Bean 定义.
build()
Psr\Container\ContainerInterface build()DefinitionConfiguration
命名空间: kuiper\di
方法
getDefinitions()
array getDefinitions()Creates php-di definitions.
MetadataComponentInterface
命名空间: kuiper\di
标记该组件属性只承载元数据,不对应可实例化的类.
方法
该接口未声明自己的方法。
Web
AttributeProcessorInterface
命名空间: kuiper\web
方法
process()
void process()Processes the annotation.
ControllerInterface
命名空间: kuiper\web\controller
方法
initialize()
initialize()Initialize controller.
withRequest()
static withRequest(Psr\Http\Message\ServerRequestInterface $request)Sets request.
withResponse()
static withResponse(Psr\Http\Message\ResponseInterface $response)Sets response.
getResponse()
Psr\Http\Message\ResponseInterface getResponse()Gets the response.
LoginUrlBuilderInterface
命名空间: kuiper\web\handler
方法
build()
string build(Psr\Http\Message\ServerRequestInterface $request)DateFormatterInterface
命名空间: kuiper\web\logging
方法
format()
string format(float $time)LogContextInterface
命名空间: kuiper\web\logging
方法
getRequest()
Psr\Http\Message\RequestInterface getRequest()Gets the request.
getResponse()
?Psr\Http\Message\ResponseInterface getResponse()Gets the response.
hasResponse()
bool hasResponse()getError()
?Throwable getError()Gets the error.
hasError()
bool hasError()getStartTime()
float getStartTime()getEndTime()
float getEndTime()getRequestTime()
float getRequestTime()LogFormatterInterface
命名空间: kuiper\web\logging
方法
format()
array format(kuiper\web\logging\LogContextInterface $context)MiddlewareFactory
命名空间: kuiper\web\middleware
方法
getPriority()
int getPriority()filter priority, the smaller one run first.
create()
Psr\Http\Server\MiddlewareInterface create(Psr\Container\ContainerInterface $container)Creates the middleware.
RateLimiterInterface
命名空间: kuiper\web\ratelimit
速率限制器接口.
方法
limit()
kuiper\web\ratelimit\RateLimitInfo limit(Psr\Http\Message\ServerRequestInterface $request)检查请求是否超过速率限制.
RequestKeyResolverInterface
命名空间: kuiper\web\ratelimit
速率限制键解析器接口.
方法
resolve()
string resolve(Psr\Http\Message\ServerRequestInterface $request)从请求中解析速率限制键.
RateLimitStorageInterface
命名空间: kuiper\web\ratelimit\Storage
速率限制存储接口.
方法
increment()
int increment(string $key, int $step, int $ttl)增加计数器值.
get()
?int get(string $key)获取计数器值.
reset()
void reset(string $key)重置计数器.
AclInterface
命名空间: kuiper\web\security
方法
isAllowed()
bool isAllowed(string $role, string $authority)Check whether a role is allowed to access the resource.
AuthInterface
命名空间: kuiper\web\security
方法
login()
void login(kuiper\web\security\UserIdentity $identity)make current user logged in.
getIdentity()
kuiper\web\security\UserIdentity getIdentity()Gets the user identity.
logout()
void logout(bool $destroySession = true)make current user logged out.
isGuest()
bool isGuest()whether current user is logged in.
isAuthorized()
bool isAuthorized()whether current user is logged in.
CsrfTokenInterface
命名空间: kuiper\web\security
方法
getTokenKey()
string getTokenKey()Gets key to be used as input's name in a CSRF check.
getToken()
string getToken()Gets token value to be used as input's value in a CSRF check.
regenerateToken()
string regenerateToken()Regenerate the CSRF token value.
checkToken()
bool checkToken(?string $tokenValue, bool $destroyIfValid = true)Check if the CSRF token is the same that the current in session.
check()
bool check(Psr\Http\Message\ServerRequestInterface $request, $destroyIfValid = true)Check if the CSRF token sent in the request is the same that the current in session.
UserIdentity
命名空间: kuiper\web\security
方法
getUsername()
string getUsername()Returns the username used to authenticate the user.
getAuthorities()
array getAuthorities()Returns the authorities granted to the user.
UserIdentityNormalizerInterface
命名空间: kuiper\web\security
UserIdentity 序列化接口.
方法
normalize()
array normalize(kuiper\web\security\UserIdentity $identity)将 UserIdentity 对象序列化为数组.
denormalize()
kuiper\web\security\UserIdentity denormalize(array $data, string $className)将数组反序列化为 UserIdentity 对象.
FlashInterface
命名空间: kuiper\web\session
方法
has()
bool has(?string $type = null)Checks whether there are messages.
error()
void error(string $message)Shows a HTML error message.
notice()
void notice(string $message)Shows a HTML notice/information message.
success()
void success(string $message)Shows a HTML success message.
warning()
void warning(string $message)Shows a HTML warning message.
message()
void message(string $type, string $message)Outputs a message.
clearAll()
void clearAll()Clears all messages.
getMessages()
array getMessages()Gets all messages.
SessionFactoryInterface
命名空间: kuiper\web\session
方法
create()
kuiper\web\session\SessionInterface create(Psr\Http\Message\ServerRequestInterface $request)SessionInterface
命名空间: kuiper\web\session
方法
start()
void start()Starts session, optionally using an adapter.
get()
mixed get(string $index, mixed $defaultValue = null)Gets a session variable from an application context.
set()
void set(string $index, mixed $value)Sets a session variable in an application context.
has()
bool has(string $index)Check whether a session variable is set in an application context.
remove()
void remove(string $index)Removes a session variable from an application context.
getId()
string getId()Returns active session id.
isStarted()
bool isStarted()Check whether the session has been started.
destroy()
bool destroy(bool $removeData = false)Destroys the active session.
regenerateId()
void regenerateId(bool $deleteOldSession = true)Regenerate session's id.
setCookie()
Psr\Http\Message\ResponseInterface setCookie(Psr\Http\Message\ResponseInterface $response)ViewAwareInterface
命名空间: kuiper\web\view
方法
setView()
void setView(kuiper\web\view\ViewInterface $view)ViewInterface
命名空间: kuiper\web\view
方法
render()
string render(string $name, array $context = [])Renders a template.
数据库
ConnectionInterface
命名空间: kuiper\db
方法
connectToDatabase()
void connectToDatabase()Connects to the database and sets PDO attributes.
disconnect()
void disconnect()Explicitly disconnect by unset the PDO instance; does not prevent
getPdo()
PDO getPdo()Returns the underlying PDO connection object.
ConnectionPoolInterface
命名空间: kuiper\db
方法
take()
kuiper\db\ConnectionInterface take()release()
void release(kuiper\db\ConnectionInterface $connection)CrudRepositoryInterface
命名空间: kuiper\db
方法
insert()
object insert(object $entity)Saves the entity.
batchInsert()
array batchInsert(array $entities)Batch insert entities.
update()
object update(object $entity)Updates the entity.
batchUpdate()
array batchUpdate(array $entities)Batch update entities.
save()
object save(object $entity)Saves the entity.
batchSave()
array batchSave(array $entities)Batch save entities.
updateBy()
void updateBy(mixed $criteria, callable|array $update)Update by criteria.
findById()
?object findById(mixed $id)Finds the entity by id.
existsById()
bool existsById(mixed $id)Returns whether an entity with the given id exists.
findFirstBy()
?object findFirstBy(mixed $criteria)Finds the entity.
findByNaturalId()
?object findByNaturalId(object $example)Find the entity by fields annotated with @{@see NaturalId}.
findAllByNaturalId()
array findAllByNaturalId(array $examples)Find all entities by fields annotated with @{@see NaturalId}.
findAllById()
array findAllById(array $ids)Returns all instances of the type with the given IDs.
findAllBy()
array findAllBy(mixed $criteria)Returns all entities match the criteria.
query()
array query(mixed $criteria)Query with the given criteria.
count()
int count(mixed $criteria)Returns row count match the criteria.
deleteById()
void deleteById(mixed $id)Finds the entity by id.
delete()
void delete(object $entity)Deletes the entity.
deleteFirstBy()
void deleteFirstBy(mixed $criteria)Delete first entity matches criteria.
deleteAllById()
void deleteAllById(array $ids)Delete all entity by id.
deleteAll()
void deleteAll(array $entities)Deletes all entities.
deleteAllBy()
void deleteAllBy(mixed $criteria)Delete all matched.
getQueryBuilder()
kuiper\db\QueryBuilderInterface getQueryBuilder()getMetaModel()
kuiper\db\metadata\MetaModelInterface getMetaModel()DateTimeFactoryInterface
命名空间: kuiper\db
方法
currentTimeString()
string currentTimeString()Returns current time string.
stringToTime()
?DateTimeInterface stringToTime(string $timeString)Parses time string to time.
timeToString()
string timeToString(DateTimeInterface $time)Formats time string.
PdoInterface
命名空间: kuiper\db
An interface to the native PDO object.
方法
beginTransaction()
bool beginTransaction()Begins a transaction and turns off autocommit mode.
commit()
bool commit()Commits the existing transaction and restores autocommit mode.
rollBack()
bool rollBack()Rolls back the current transaction and restores autocommit mode.
errorCode()
string errorCode()Gets the most recent error code.
errorInfo()
array errorInfo()Gets the most recent error info.
exec()
int exec($statement)Executes an SQL statement and returns the number of affected rows.
inTransaction()
bool inTransaction()Is a transaction currently active?
lastInsertId()
string|false lastInsertId(?string $name = null)Returns the last inserted autoincrement sequence value.
prepare()
PDOStatement|false prepare(string $query, array $options = [])Prepares an SQL statement for execution.
query()
PDOStatement|false query($statement, $mode = PDO::ATTR_DEFAULT_FETCH_MODE, ...$fetch_mode_args)Queries the database and returns a PDOStatement.
quote()
string quote($value, $parameter_type = PDO::PARAM_STR)Quotes a value for use in an SQL statement.
setAttribute()
bool setAttribute($attribute, $value)Sets a PDO attribute value.
getAttribute()
mixed getAttribute(int $attribute)Gets a PDO attribute value.
getAvailableDrivers()
static array getAvailableDrivers()Returns all currently available PDO drivers.
QueryBuilderInterface
命名空间: kuiper\db
方法
from()
kuiper\db\StatementInterface from(string $table)Create select statement.
delete()
kuiper\db\StatementInterface delete(string $table)Create delete statement.
update()
kuiper\db\StatementInterface update(string $table)Create update statement.
insert()
kuiper\db\StatementInterface insert(string $table)Create insert statement.
StatementInterface
命名空间: kuiper\db
Interface StatementInterface.
方法
getLastInsertId()
?string getLastInsertId()获取最后插入记录的自增 ID.
tableAlias()
tableAlias(string $alias)Sets table alias.
select()
select(...$columns)Sets selected columns.
where()
where(mixed $condition, ...$args)Sets where statement.
bindValue()
bindValue(string $name, mixed $value)Sets the binding parameter.
orWhere()
orWhere(mixed $condition, ...$args)like()
like(string $column, string $value)Sets like statement.
in()
in(string $column, array $values)Sets in statement.
orIn()
orIn(string $column, array $values)notIn()
notIn(string $column, array $values)orNotIn()
orNotIn(string $column, array $values)limit()
limit(int $limit)offset()
offset(int $offset)orderBy()
orderBy(array $orderSpec)groupBy()
groupBy(array $columns)cols()
cols(array $values)addRow()
addRow(array $values = [])execute()
bool execute()Executes statement.
query()
query()Executes query statement.
rowCount()
int rowCount()Gets affected rows.
close()
void close()close statement.
withConnection()
void withConnection(callable $call)Gets the db connection.
fetch()
mixed fetch(?int $fetchStyle = null)fetchColumn()
mixed fetchColumn(int $columnNumber = 0)fetchAll()
array fetchAll(?int $fetchStyle = null)TransactionManagerInterface
命名空间: kuiper\db
方法
transaction()
mixed transaction(callable $callback)Attribute
命名空间: kuiper\db\attribute
方法
该接口未声明自己的方法。
AttributeConverterInterface
命名空间: kuiper\db\converter
方法
convertToDatabaseColumn()
mixed convertToDatabaseColumn(mixed $attribute, kuiper\db\metadata\ColumnInterface $column)Converts the value stored in the entity attribute into the
convertToEntityAttribute()
mixed convertToEntityAttribute(mixed $dbData, kuiper\db\metadata\ColumnInterface $column)Converts the data stored in the database column into the
CriteriaClauseInterface
命名空间: kuiper\db\criteria
方法
该接口未声明自己的方法。
CriteriaFilterInterface
命名空间: kuiper\db\criteria
方法
filter()
kuiper\db\criteria\CriteriaClauseInterface filter(kuiper\db\criteria\CriteriaClauseInterface $clause)Exception
命名空间: kuiper\db\exception
方法
该接口未声明自己的方法。
ColumnInterface
命名空间: kuiper\db\metadata
方法
getName()
string getName()Gets the column name.
getType()
kuiper\reflection\ReflectionTypeInterface getType()Gets the php type.
getPropertyPath()
string getPropertyPath()Gets the object property path.
getProperty()
kuiper\db\metadata\MetaModelProperty getProperty()Gets the property meta data.
EntityMapperInterface
命名空间: kuiper\db\metadata
方法
freeze()
array freeze(object $entity, bool $ignoreNull = true)Converts entity object to database column values.
thaw()
object thaw(array $columnValues)Converts database column values.
getValue()
mixed getValue(object $entity, string $columnName)Gets the database column value from entity object.
setValue()
void setValue(object $entity, string $columnName, mixed $value)Sets the entity property value.
idToPrimaryKey()
array idToPrimaryKey(mixed $id)Converts id value to database column value.
MetaModelFactoryInterface
命名空间: kuiper\db\metadata
方法
create()
kuiper\db\metadata\MetaModelInterface create(string $entityClass)Creates the table metadata.
createFromRepository()
kuiper\db\metadata\MetaModelInterface createFromRepository(string $repositoryClass)Creates the table metadata by repository.
MetaModelInterface
命名空间: kuiper\db\metadata
方法
getTable()
string getTable()Gets the table name.
getEntityClass()
ReflectionClass getEntityClass()Gets the class.
getColumnNames()
array getColumnNames()Gets the database column names.
getColumns()
array getColumns()Gets the column objects.
getCreationTimestamp()
?string getCreationTimestamp()Gets the creation timestamp column name.
getUpdateTimestamp()
?string getUpdateTimestamp()Gets the update timestamp column name.
getAutoIncrement()
?string getAutoIncrement()Gets the auto increment column name.
getNaturalIdIndex()
?string getNaturalIdIndex()Gets the unique key index name.
getIdValues()
?array getIdValues(object $entity)Gets the database column values that annotated with {@see Id} or {@see NaturalId}.
getNaturalIdValues()
?array getNaturalIdValues(object $entity)Gets the database column values that annotated with {@see NaturalId}.
getUniqueKey()
string getUniqueKey(object $entity, string $joiner = '', bool $ignoreCase = true)Gets the unique key by join natural id values.
getId()
getId(object $entity)Gets the property value annotated with {@see Id}.
getProperty()
?kuiper\db\metadata\MetaModelProperty getProperty(string $propertyPath)Gets the property.
filterCriteria()
kuiper\db\Criteria filterCriteria(kuiper\db\Criteria $criteria)Filters the criteria.
NamingStrategyInterface
命名空间: kuiper\db\metadata
方法
toTableName()
string toTableName(kuiper\db\metadata\NamingContext $context)Converts table name to physical table name.
toColumnName()
string toColumnName(kuiper\db\metadata\NamingContext $context)Converts column name to physical column name.
ClusterInterface
命名空间: kuiper\db\sharding
方法
getTableStrategy()
kuiper\db\sharding\StrategyInterface getTableStrategy(string $table)Gets the table sharding strategy.
ConnectionFactoryInterface
命名空间: kuiper\db\sharding
方法
create()
kuiper\db\ConnectionInterface create(int $connectionId)Creates the connection.
StatementInterface
命名空间: kuiper\db\sharding
方法
shardBy()
void shardBy(array $fields)Sets the sharding field values.
getShardBy()
array getShardBy()getBaseTable()
string getBaseTable()Gets the original name of the table.
getTableStrategy()
kuiper\db\sharding\StrategyInterface getTableStrategy()Gets the sharding strategy.
StrategyInterface
命名空间: kuiper\db\sharding
方法
getTable()
string getTable(array $fields, string $table)Gets the partition table name.
getDb()
int getDb(array $fields)Gets the connection id.
RuleInterface
命名空间: kuiper\db\sharding\rule
方法
getPartition()
string|int getPartition(array $fields)Gets the sharding partition.
RPC
RpcRequestHandlerInterface
命名空间: kuiper\rpc
客户端和服务端共享的 RPC 请求处理器契约.
方法
handle()
kuiper\rpc\message\RpcResponseInterface handle(kuiper\rpc\message\RpcRequestInterface $request)ProxyGeneratorInterface
命名空间: kuiper\rpc\client
方法
generate()
mixed generate(string $interfaceName, array $context = [])RequestHandlerInterface
命名空间: kuiper\rpc\client
客户端请求处理器(保留以兼容已有类型声明).
方法
该接口未声明自己的方法。
RpcExecutorFactoryInterface
命名空间: kuiper\rpc\client
方法
createExecutor()
kuiper\rpc\client\RpcExecutorInterface createExecutor(object $proxy, string $method, array $args)RpcExecutorInterface
命名空间: kuiper\rpc\client
方法
execute()
mixed execute()返回方法调用的结果(即方法的返回值,不含 out 参数).
executeAll()
array executeAll()协议无关地返回全部结果.
RpcRequestFactoryInterface
命名空间: kuiper\rpc\client
方法
createRequest()
kuiper\rpc\message\RpcRequestInterface createRequest(object $proxy, string $method, array $args)RpcResponseFactoryInterface
命名空间: kuiper\rpc\client
方法
createResponse()
kuiper\rpc\message\RpcResponseInterface createResponse(kuiper\rpc\message\RpcRequestInterface $request, mixed $result)createErrorResponse()
kuiper\rpc\message\RpcResponseInterface createErrorResponse(kuiper\rpc\message\RpcRequestInterface $request, Throwable $error)CircuitBreakerMetricsInterface
命名空间: kuiper\rpc\client\middleware
Observer interface for CircuitBreaker state transitions and call outcomes. Implementations can export metrics to Prometheus, StatsD, or any monitoring system.
方法
onSuccess()
void onSuccess(string $serviceName)Called when a call succeeds.
onFailure()
void onFailure(string $serviceName)Called when a call fails.
onCallNotPermitted()
void onCallNotPermitted(string $serviceName)Called when a call is rejected because the circuit is open.
onStateTransition()
void onStateTransition(string $serviceName, int $fromState, int $toState)Called when the circuit state transitions.
MiddlewareInterface
命名空间: kuiper\rpc\client\middleware
方法
该接口未声明自己的方法。
CodecInterface
命名空间: kuiper\rpc\codec
方法
该接口未声明自己的方法。
RequestCodecInterface
命名空间: kuiper\rpc\codec
方法
supports()
bool supports(string $protocol, string $serialization)encodeRequest()
kuiper\rpc\transporter\message\TransportRequestInterface encodeRequest(kuiper\rpc\message\RpcRequestInterface $request)Encode an RPC request into a transport request.
decodeRequest()
kuiper\rpc\message\RpcRequestInterface decodeRequest(kuiper\rpc\transporter\message\TransportRequestInterface $message)Decode a transport request into an RPC request.
ResponseCodecInterface
命名空间: kuiper\rpc\codec
方法
supports()
bool supports(string $protocol, string $serialization)encodeResponse()
kuiper\rpc\transporter\message\TransportResponseInterface encodeResponse(kuiper\rpc\message\RpcResponseInterface $response)Encode an RPC response into a transport response.
decodeResponse()
kuiper\rpc\message\RpcResponseInterface decodeResponse(kuiper\rpc\transporter\message\TransportResponseInterface $message, ?kuiper\rpc\message\RpcRequestInterface $request = null)Decode a transport response into an RPC response.
RpcContextInterface
命名空间: kuiper\rpc\message
方法
getTraceId()
?string getTraceId()getSpanId()
?string getSpanId()getParentSpanId()
?string getParentSpanId()withTrace()
static withTrace(string $traceId, string $spanId, ?string $parentSpanId = null)fromAttributes()
static static fromAttributes(array $attributes)RpcMethodInterface
命名空间: kuiper\rpc\message
方法
getTarget()
object|string getTarget()getTargetClass()
string getTargetClass()getServiceLocator()
kuiper\rpc\message\ServiceLocatorInterface getServiceLocator()getMethodName()
string getMethodName()getArguments()
array getArguments()withArguments()
static withArguments(array $args)getResult()
array getResult()withResult()
static withResult(array $result)RpcRequestInterface
命名空间: kuiper\rpc\message
方法
getRpcMethod()
kuiper\rpc\message\RpcMethodInterface getRpcMethod()withRpcMethod()
static withRpcMethod(kuiper\rpc\message\RpcMethodInterface $rpcMethod)getEndpoint()
?kuiper\rpc\transporter\Endpoint getEndpoint()withEndpoint()
static withEndpoint(kuiper\rpc\transporter\Endpoint $endpoint)getAttributes()
array getAttributes()getAttribute()
mixed getAttribute(string $name, mixed $default = null)withAttribute()
static withAttribute(string $name, mixed $value)RpcResponseInterface
命名空间: kuiper\rpc\message
方法
getRequest()
kuiper\rpc\message\RpcRequestInterface getRequest()getResult()
array getResult()withResult()
static withResult(array $result)getError()
?Throwable getError()withError()
static withError(Throwable $error)RpcServerRequestInterface
命名空间: kuiper\rpc\message
方法
getRpcMethod()
kuiper\rpc\message\RpcMethodInterface getRpcMethod()getServiceLocator()
kuiper\rpc\message\ServiceLocatorInterface getServiceLocator()ServiceLocatorInterface
命名空间: kuiper\rpc\message
方法
getName()
string getName()getNamespace()
string getNamespace()getVersion()
string getVersion()equals()
bool equals(kuiper\rpc\message\ServiceLocatorInterface $other)__toString()
string __toString()返回可用于注册表精确匹配的稳定字符串 key.
MiddlewareFactoryInterface
命名空间: kuiper\rpc\middleware
方法
getPriority()
int getPriority()MiddlewareInterface
命名空间: kuiper\rpc\middleware
方法
process()
kuiper\rpc\message\RpcResponseInterface process(kuiper\rpc\message\RpcRequestInterface $request, kuiper\rpc\RpcRequestHandlerInterface $handler)RpcServerResponseFactoryInterface
命名空间: kuiper\rpc\server
方法
createResponse()
kuiper\rpc\message\RpcResponseInterface createResponse(kuiper\rpc\message\RpcRequestInterface $request, mixed $result)createResultResponse()
kuiper\rpc\message\RpcResponseInterface createResultResponse(kuiper\rpc\message\RpcRequestInterface $request, array $results)用 [返回值, ...out 参数] 的全部结果创建响应(TARS 多输出参数协议).
createErrorResponse()
kuiper\rpc\message\RpcResponseInterface createErrorResponse(kuiper\rpc\message\RpcRequestInterface $request, Throwable $error)ServerRequestHandlerInterface
命名空间: kuiper\rpc\server
服务端请求处理器(保留以兼容已有类型声明).
方法
该接口未声明自己的方法。
ServiceRegistryInterface
命名空间: kuiper\rpc\server
方法
getService()
?object getService(kuiper\rpc\message\ServiceLocatorInterface $locator)register()
void register(string $serviceName, object $serviceInstance)registerService()
void registerService(kuiper\rpc\message\ServiceLocatorInterface $locator, object $serviceInstance)按完整 ServiceLocator(name + namespace + version)注册服务.
deregister()
void deregister(string $serviceName)getServices()
array getServices()ServiceResolverInterface
命名空间: kuiper\rpc\servicediscovery
方法
resolve()
?kuiper\rpc\servicediscovery\ServiceEndpoint resolve(kuiper\rpc\message\ServiceLocatorInterface $serviceLocator)DnsResolverInterface
命名空间: kuiper\rpc\servicediscovery\dns
DNS 解析器接口.
方法
resolve()
array resolve(string $hostname)解析主机名.
LoadBalanceInterface
命名空间: kuiper\rpc\servicediscovery\loadbalance
负载均衡接口.
方法
select()
mixed select()选择下一个候选.
Closable
命名空间: kuiper\rpc\transporter
方法
close()
void close()TransporterFactoryInterface
命名空间: kuiper\rpc\transporter
方法
create()
kuiper\rpc\transporter\TransporterInterface create(kuiper\rpc\transporter\Endpoint $endpoint)TransporterInterface
命名空间: kuiper\rpc\transporter
方法
send()
kuiper\rpc\transporter\message\TransportResponseInterface send(kuiper\rpc\transporter\message\TransportRequestInterface $request)sendDirect()
kuiper\rpc\transporter\message\TransportResponseInterface sendDirect(mixed $connection, kuiper\rpc\transporter\message\TransportRequestInterface $request)Send request using an already-established connection.
TransportRequestInterface
命名空间: kuiper\rpc\transporter\message
方法
getContent()
string getContent()getMetadata()
array getMetadata()TransportResponseInterface
命名空间: kuiper\rpc\transporter\message
方法
getContent()
string getContent()getMetadata()
array getMetadata()缓存
CacheConstants
命名空间: kuiper\cache\stash
Cache constants.
方法
该接口未声明自己的方法。
DriverInterface
命名空间: kuiper\cache\stash
方法
getData()
array getData(string $key)Returns the previously stored data as well as its expiration date in an associative array. This array contains
storeData()
bool storeData(string $key, mixed $data, int $expiration)Takes in data from the exposed Stash class and stored it for later retrieval.
clear()
bool clear(?string $key = null)Clears the cache tree using the key array provided as the key. If called with no arguments the entire cache gets
purge()
bool purge()Remove any expired code from the cache. For some drivers this can just return true, as their underlying engines
序列化
JsonSerializerInterface
命名空间: kuiper\serializer
方法
toJson()
string toJson(mixed $data, int $options = 0)Serializes data into json.
fromJson()
mixed fromJson(string $jsonString, object|string $type)Converts json to object.
NormalizerInterface
命名空间: kuiper\serializer
方法
normalize()
mixed normalize(mixed $object)Normalizes the object into an array of scalars|arrays.
denormalize()
mixed denormalize(mixed $data, kuiper\reflection\ReflectionTypeInterface|string $dataType)Turn data back into an object of the given class.
SerializerInterface
命名空间: kuiper\serializer
统一序列化器接口.
方法
该接口未声明自己的方法。
日志
LoggerFactoryInterface
命名空间: kuiper\logger
方法
create()
Psr\Log\LoggerInterface create(?string $className = null)Creates logger for the class.
可观测性
TelemetryFlushable
命名空间: kuiper\otel
标记"这是一个适合冲刷 telemetry 的边界".
方法
该接口未声明自己的方法。
容错
CircuitBreaker
命名空间: kuiper\resilience\circuitbreaker
熔断器接口.
方法
decorate()
callable decorate(callable $call)装饰一个待保护的调用.
call()
mixed call(callable $call, mixed ...$args)通过熔断器执行一次调用.
getName()
string getName()熔断器的名称.
getMetrics()
kuiper\resilience\circuitbreaker\CircuitBreakerMetrics getMetrics()获取熔断器的度量指标.
CircuitBreakerFactory
命名空间: kuiper\resilience\circuitbreaker
熔断器工厂接口.
方法
create()
kuiper\resilience\circuitbreaker\CircuitBreaker create(string $name)按名称获取熔断器,同名熔断器会被复用.
CircuitBreakerMetrics
命名空间: kuiper\resilience\circuitbreaker
熔断器度量指标接口.
方法
getFailureRate()
float getFailureRate()返回当前失败率(百分比).
getSlowCallRate()
float getSlowCallRate()返回当前慢调用率(百分比).
getNumberOfSlowCalls()
int getNumberOfSlowCalls()返回当前慢调用总数.
getNumberOfSlowSuccessfulCalls()
int getNumberOfSlowSuccessfulCalls()返回当前成功的慢调用数量.
getNumberOfSlowFailedCalls()
int getNumberOfSlowFailedCalls()返回当前失败的慢调用数量.
getNumberOfBufferedCalls()
int getNumberOfBufferedCalls()返回当前滑动窗口中缓冲的调用总数.
getNumberOfFailedCalls()
int getNumberOfFailedCalls()返回当前滑动窗口中缓冲的失败调用数.
getNumberOfNotPermittedCalls()
int getNumberOfNotPermittedCalls()返回当前被拒绝的调用数量.
getNumberOfSuccessfulCalls()
int getNumberOfSuccessfulCalls()返回当前滑动窗口中缓冲的成功调用数.
reset()
void reset()重置度量指标.
onCallNotPermitted()
void onCallNotPermitted()记录一次被拒绝的调用.
onSuccess()
kuiper\resilience\circuitbreaker\Result onSuccess(int $duration)记录一次成功调用并检查阈值.
onError()
kuiper\resilience\circuitbreaker\Result onError(int $duration)记录一次失败调用并检查阈值.
CircuitBreakerState
命名空间: kuiper\resilience\circuitbreaker
熔断器状态机接口.
方法
tryAcquirePermission()
bool tryAcquirePermission()尝试获取调用许可.
acquirePermission()
void acquirePermission()获取调用许可,不允许时抛出异常.
releasePermission()
void releasePermission()释放调用许可.
onError()
void onError(int $duration, Exception $exception)记录一次失败调用.
onSuccess()
void onSuccess(int $duration)记录一次成功调用.
attempts()
int attempts()当前状态已经尝试的次数.
getState()
kuiper\resilience\circuitbreaker\State getState()当前状态.
StateStore
命名空间: kuiper\resilience\circuitbreaker
熔断器状态存储接口.
方法
getState()
kuiper\resilience\circuitbreaker\State getState(string $name)读取指定熔断器的状态.
setState()
void setState(string $name, kuiper\resilience\circuitbreaker\State $state)写入指定熔断器的状态.
getOpenAt()
int getOpenAt(string $name)读取指定熔断器进入 OPEN 状态的时间戳(毫秒),未处于 OPEN 状态时返回 0.
clear()
void clear(string $name)清除指定熔断器的状态.
Clock
命名空间: kuiper\resilience\core
时钟抽象.
方法
getEpochSecond()
int getEpochSecond()获取当前时间戳(秒).
getTimeInMillis()
int getTimeInMillis()获取当前时间戳(毫秒).
sleep()
void sleep(int $millis)休眠指定的毫秒数.
Counter
命名空间: kuiper\resilience\core
计数器抽象.
方法
get()
int get()获取当前值.
set()
void set(int $value)设置当前值.
increment()
int increment(int $value = 1)自增并返回自增后的值.
decrement()
int decrement(int $value = 1)自减并返回自减后的值.
CounterFactory
命名空间: kuiper\resilience\core
计数器工厂.
方法
create()
kuiper\resilience\core\Counter create(string $name)创建(或复用)一个计数器.
Metrics
命名空间: kuiper\resilience\core
滑动窗口指标.
方法
record()
kuiper\resilience\core\Snapshot record(int $duration, kuiper\resilience\core\Outcome $outcome)记录一次调用.
reset()
void reset()重置所有统计量.
getSnapshot()
kuiper\resilience\core\Snapshot getSnapshot()返回当前窗口的快照.
getWindowSize()
int getWindowSize()返回窗口大小.
getWindowType()
kuiper\resilience\circuitbreaker\SlideWindowType getWindowType()返回窗口类型.
MetricsFactory
命名空间: kuiper\resilience\core
滑动窗口指标工厂.
方法
create()
kuiper\resilience\core\Metrics create(string $name, kuiper\resilience\circuitbreaker\SlideWindowType $type, int $windowSize)创建(或复用)一个滑动窗口指标.
ResilienceException
命名空间: kuiper\resilience\core
弹性组件异常标记接口.
方法
该接口未声明自己的方法。
Retry
命名空间: kuiper\resilience\retry
重试器.
方法
getName()
string getName()重试器的名称.
decorate()
callable decorate(callable $call)创建一个带重试能力的可调用对象.
call()
mixed call(callable $call, ...$args)执行调用,失败时按照配置重试.
getMetrics()
kuiper\resilience\retry\RetryMetrics getMetrics()获取最近一次调用(以及历史累计)的统计指标.
RetryFactory
命名空间: kuiper\resilience\retry
重试器工厂.
方法
create()
kuiper\resilience\retry\Retry create(string $name)根据名称创建(或者复用)一个重试器.
RetryMetrics
命名空间: kuiper\resilience\retry
重试统计指标.
方法
getNumberOfSuccessfulCallsWithoutRetryAttempt()
int getNumberOfSuccessfulCallsWithoutRetryAttempt()返回没有发生重试就成功的调用次数.
getNumberOfFailedCallsWithoutRetryAttempt()
int getNumberOfFailedCallsWithoutRetryAttempt()返回没有发生重试就失败的调用次数.
getNumberOfSuccessfulCallsWithRetryAttempt()
int getNumberOfSuccessfulCallsWithRetryAttempt()返回重试之后成功的调用次数.
getNumberOfFailedCallsWithRetryAttempt()
int getNumberOfFailedCallsWithRetryAttempt()返回重试之后依然失败的调用次数.
反射
ReflectionAttributeInterface
命名空间: kuiper\reflection
Interface for attribute metadata. Provides static analysis information about PHP 8 attributes.
方法
getName()
string getName()Gets the attribute name.
getArguments()
array getArguments()Gets the attribute arguments.
newInstance()
object newInstance()Creates the attribute instance.
toArray()
array toArray()Serializes to array for caching.
fromArray()
static self fromArray(array $data)Creates from cached array.
ReflectionClassInterface
命名空间: kuiper\reflection
Interface for class metadata. Method names are consistent with \ReflectionClass for familiarity.
方法
getName()
string getName()Gets the class name.
getNamespaceName()
string getNamespaceName()Gets the namespace name.
getFileName()
string getFileName()Gets the filename of the file where the class is defined.
isInterface()
bool isInterface()Checks if the class is an interface.
isTrait()
bool isTrait()Checks if the class is a trait.
isAbstract()
bool isAbstract()Checks if the class is abstract.
isFinal()
bool isFinal()Checks if the class is final.
isReadOnly()
bool isReadOnly()Checks if the class is readonly.
isInstantiable()
bool isInstantiable()Checks if the class is instantiable.
getParentClass()
?string getParentClass()Gets the parent class name.
getInterfaceNames()
array getInterfaceNames()Gets the interface names.
getTraitNames()
array getTraitNames()Gets the trait names.
toReflectionClass()
ReflectionClass toReflectionClass()toArray()
array toArray()Serializes to array for caching.
fromArray()
static self fromArray(array $data)Creates from cached array.
getAttributes()
array getAttributes(?string $name = null, int $flags = 0)Gets all attribute metadata.
hasAttribute()
bool hasAttribute(string $attributeName)Checks if class has a specific attribute.
ReflectionDocBlockFactoryInterface
命名空间: kuiper\reflection
方法
createPropertyDocBlock()
kuiper\reflection\ReflectionPropertyDocBlockInterface createPropertyDocBlock(ReflectionProperty $property)createMethodDocBlock()
kuiper\reflection\ReflectionMethodDocBlockInterface createMethodDocBlock(ReflectionMethod $method)ReflectionDocBlockInterface
命名空间: kuiper\reflection
方法
该接口未声明自己的方法。
ReflectionMethodDocBlockInterface
命名空间: kuiper\reflection
方法
getParameterTypes()
array getParameterTypes()Parses the docblock of the method to get all parameters type.
getReturnType()
kuiper\reflection\ReflectionTypeInterface getReturnType()Parses the docblock of the method to get return type.
ReflectionPropertyDocBlockInterface
命名空间: kuiper\reflection
方法
getType()
kuiper\reflection\ReflectionTypeInterface getType()Parse the docblock of the property to get the class of the var annotation.
ReflectionTypeInterface
命名空间: kuiper\reflection
方法
getName()
string getName()Gets type string.
allowsNull()
bool allowsNull()Checks if null is allowed.
withAllowsNull()
kuiper\reflection\ReflectionTypeInterface withAllowsNull(bool $allowsNull)Returns a new instance with the specified nullability setting.
__toString()
string __toString()isPrimitive()
bool isPrimitive()Checks if the type is a primitive type.
isArray()
bool isArray()Checks if the type is an array type.
isScalar()
bool isScalar()Checks if the type is a scalar type.
isCompound()
bool isCompound()Checks if the type is a compound type.
isPseudo()
bool isPseudo()Checks if the type is a pseudo type.
isNull()
bool isNull()Checks if the type is the null type.
isResource()
bool isResource()Checks if the type is a resource type.
isClass()
bool isClass()Checks if the type is a class type.
isObject()
bool isObject()Checks if the type is an object type.
isComposite()
bool isComposite()Checks if the type is a composite (union) type.
isUnknown()
bool isUnknown()Checks if the type is an unknown type.
equals()
bool equals(kuiper\reflection\ReflectionTypeInterface $other)Checks if the type is equal to another type.
TypeFilterInterface
命名空间: kuiper\reflection
方法
isValid()
bool isValid(mixed $value)checks whether the value is valid.
sanitize()
mixed sanitize(mixed $value)Sanitizes input value.
TypeFilterRegistryInterface
命名空间: kuiper\reflection
Type filter registry interface.
方法
register()
void register(string $typeClass, string $filterClass)Registers the mapping relationship between type and filter.
has()
bool has(string $typeClass)Checks if a filter is registered for the specified type.
getFilter()
?kuiper\reflection\TypeFilterInterface getFilter(kuiper\reflection\ReflectionTypeInterface $type)Gets the filter instance for the specified type.
getRegisteredTypes()
array getRegisteredTypes()Gets all registered type class names.
TypeParserInterface
命名空间: kuiper\reflection
方法
parse()
kuiper\reflection\ReflectionTypeInterface parse(string $typeString)Parses a type string into a ReflectionTypeInterface instance.
Swoole
CounterInterface
命名空间: kuiper\swoole\concurrency
方法
add()
int add(int $value = 1)增加计数器并返回新值.
get()
int get()获取当前值.
set()
void set(int $value)设置计数器值.
LockInterface
命名空间: kuiper\swoole\concurrency
方法
lock()
bool lock()获取锁.
unlock()
bool unlock()释放锁.
trylock()
bool trylock()尝试获取锁(非阻塞).
ChannelInterface
命名空间: kuiper\swoole\coroutine
方法
push()
bool push($data, ?float $timeout = null)pop()
pop(?float $timeout = null)size()
int size()PoolExceptionInterface
命名空间: kuiper\swoole\exception
Interface for pool-related exceptions.
方法
该接口未声明自己的方法。
ConnectionHealthCheckInterface
命名空间: kuiper\swoole\pool
Interface for checking connection health.
方法
isHealthy()
bool isHealthy(mixed $resource)Check if a connection resource is healthy and can be used.
ConnectionInterface
命名空间: kuiper\swoole\pool
方法
getResource()
mixed getResource()Gets the resource object.
getId()
int getId()Gets the connection id.
getCreatedAt()
float getCreatedAt()Gets the created time.
close()
void close()Close the connection.
ConnectionWarmupInterface
命名空间: kuiper\swoole\pool
Interface for connection warmup. Connection warmup is used to perform initialization operations on newly created connections before they are used.
方法
warmup()
void warmup(mixed $resource)Warms up a connection resource.
PoolFactoryInterface
命名空间: kuiper\swoole\pool
方法
create()
kuiper\swoole\pool\PoolInterface create(string $poolName, callable $connectionFactory)Create pool.
PoolInterface
命名空间: kuiper\swoole\pool
方法
take()
mixed take()release()
void release(mixed $connection)Release the connection back to the pool (connection is healthy).
discard()
void discard(mixed $connection)Discard a broken connection permanently (will not be reused).
close()
void close()Close the pool.
getName()
string getName()Gets the pool name.
PoolLifecycleListenerInterface
命名空间: kuiper\swoole\pool
Interface for listening to pool lifecycle events.
方法
onPoolInitialize()
void onPoolInitialize(kuiper\swoole\pool\PoolInterface $pool)Called when the pool is initialized.
onPoolClose()
void onPoolClose(kuiper\swoole\pool\PoolInterface $pool)Called when the pool is closed.
onConnectionCreate()
void onConnectionCreate(kuiper\swoole\pool\ConnectionInterface $connection)Called after a connection is created.
onConnectionRelease()
void onConnectionRelease(kuiper\swoole\pool\ConnectionInterface $connection)Called before a connection is released back to the pool.
onConnectionDestroy()
void onConnectionDestroy(kuiper\swoole\pool\ConnectionInterface $connection)Called before a connection is destroyed.
PoolStatisticsInterface
命名空间: kuiper\swoole\pool
Interface for pool statistics.
方法
getActiveConnections()
int getActiveConnections()Gets the number of active connections.
getIdleConnections()
int getIdleConnections()Gets the number of idle connections in the pool.
getWaitingCoroutines()
int getWaitingCoroutines()Gets the number of coroutines waiting for a connection.
getTotalCreated()
int getTotalCreated()Gets the total number of connections created.
getTotalDestroyed()
int getTotalDestroyed()Gets the total number of connections destroyed.
getAverageWaitTime()
float getAverageWaitTime()Gets the average wait time in seconds for acquiring a connection.
getStatistics()
array getStatistics()Gets all statistics as an array.
事件
AsyncEventDispatcherInterface
命名空间: kuiper\event
方法
dispatchAsync()
void dispatchAsync(object $event)EventDispatcherAwareInterface
命名空间: kuiper\event
方法
setEventDispatcher()
void setEventDispatcher(Psr\EventDispatcher\EventDispatcherInterface $eventDispatcher)Sets the event dispatcher object.
EventListenerInterface
命名空间: kuiper\event
方法
__invoke()
void __invoke(object $event)getSubscribedEvent()
string getSubscribedEvent()Returns the event name this event listener wants to listen to.
EventRegistryInterface
命名空间: kuiper\event
方法
addListener()
void addListener(string $eventName, callable $listener, int $priority = 0)Adds an event listener that listens on the specified events.
reset()
void reset()Removes all event listeners.
EventSubscriberInterface
命名空间: kuiper\event
方法
__invoke()
void __invoke(object $event)getSubscribedEvents()
array getSubscribedEvents()Returns the event name this event listener wants to listen to.
工具
ConfigAwareInterface
命名空间: kuiper\helper
方法
setConfig()
void setConfig(kuiper\helper\ConfigInterface $config)ConfigInterface
命名空间: kuiper\helper
方法
get()
mixed get(string $key, mixed $default = null)Finds an entry.
set()
void set(string $key, mixed $value)Set a value.
getInt()
int getInt(string $key, int $default = 0)Gets an integer value from the configuration.
getFloat()
float getFloat(string $key, float $default = 0.0)Gets a float value from the configuration.
getBool()
bool getBool(string $key, bool $default = false)Gets a boolean value from the configuration.
getString()
string getString(string $key, string $default = '')Gets a string value from the configuration.
has()
bool has(string $key)Returns true if the entry exists.
replace()
void replace(array $other)Merge other config, overwrite existing keys.
merge()
void merge(array $other)Merge other config, keep existing keys.
mergeWhenAbsent()
void mergeWhenAbsent(array $other)Merge other config when key not exists.
HTTP 客户端
HttpClientFactoryInterface
命名空间: kuiper\http\client
方法
create()
GuzzleHttp\ClientInterface create(array $options = [])