import { type Client } from "./Client";
import type { Island } from "./Island";
import type { Query } from "./Query";
import type { QueryAnnotation } from "./QueryAnnotation";
import type { Timeline } from "./Timeline";
/**
 * Master freshness: reads always go to master.
 */
export declare const MASTER: unique symbol;
/**
 * Stale replica freshness: reads always go to a replica, even if it's stale.
 */
export declare const STALE_REPLICA: unique symbol;
/**
 * Shard lives within an Island with one master and N replicas.
 */
export declare class Shard<TClient extends Client> {
    /** Shard number. */
    readonly no: number;
    /** A middleware to wrap queries with. It's responsible for locating the
     * right Island and retrying the call to body() (i.e. failed queries) in
     * case e.g. a shard is moved to another Island. */
    readonly runOnShard: <TRes>(shardNo: number, body: (island: Island<TClient>, attempt: number) => Promise<TRes>, onAttemptError?: (error: unknown, attempt: number) => void) => Promise<TRes>;
    private shardClients;
    /** The last known Island number where this Shard was discovered. It may be
     * out of date after the Shard is moved, and also it may be null in case there
     * was no discovery happened yet. */
    readonly lastKnownIslandNo: number | null;
    constructor(
    /** Shard number. */
    no: number, 
    /** A middleware to wrap queries with. It's responsible for locating the
     * right Island and retrying the call to body() (i.e. failed queries) in
     * case e.g. a shard is moved to another Island. */
    runOnShard: <TRes>(shardNo: number, body: (island: Island<TClient>, attempt: number) => Promise<TRes>, onAttemptError?: (error: unknown, attempt: number) => void) => Promise<TRes>);
    /**
     * Chooses the right Client to be used for this Shard. We don't memoize,
     * because the Shard may relocate to another Island during re-discovery.
     */
    client(timeline: Timeline | typeof MASTER | typeof STALE_REPLICA): Promise<TClient>;
    /**
     * Runs a query after choosing the right Client (destination connection,
     * Shard, annotation etc.)
     */
    run<TOutput>(query: Query<TOutput>, annotation: QueryAnnotation, timeline: Timeline, freshness: null | typeof MASTER | typeof STALE_REPLICA, onAttemptError?: (error: unknown, attempt: number) => void): Promise<TOutput>;
    /**
     * Throws if this Shard does not exist, or its Island is down, or something
     * else is wrong with it.
     */
    assertDiscoverable(): Promise<void>;
    private clientImpl;
    /**
     * Returns a Shard-aware Client from an Island Client.
     */
    private withShard;
}
//# sourceMappingURL=Shard.d.ts.map