rocketmq-client-nodejs
Version:
RocketMQ Node.js Client
110 lines (109 loc) • 3.62 kB
TypeScript
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* OffsetOption type enum.
*/
export declare enum OffsetType {
POLICY = 0,
OFFSET = 1,
TAIL_N = 2,
TIMESTAMP = 3
}
/**
* ProtoBuf OffsetOption type.
*/
import { OffsetOption as ProtoOffsetOption } from '../../proto/apache/rocketmq/v2/definition_pb';
/**
* OffsetOption for specifying consume from offset.
*
* <p>OffsetOption is used to specify the starting point for message consumption.
* It supports various policies and custom offsets.</p>
*/
export declare class OffsetOption {
/** Policy constant: last offset */
static readonly POLICY_LAST_VALUE: bigint;
/** Policy constant: min offset */
static readonly POLICY_MIN_VALUE: bigint;
/** Policy constant: max offset */
static readonly POLICY_MAX_VALUE: bigint;
/** Predefined option: LAST_OFFSET */
static readonly LAST_OFFSET: OffsetOption;
/** Predefined option: MIN_OFFSET */
static readonly MIN_OFFSET: OffsetOption;
/** Predefined option: MAX_OFFSET */
static readonly MAX_OFFSET: OffsetOption;
private readonly type;
private readonly value;
private constructor();
/**
* Create an OffsetOption from a specific offset.
*
* @param offset - The offset value (must be >= 0)
* @return OffsetOption instance
* @throws Error if offset is negative
*/
static ofOffset(offset: number | bigint): OffsetOption;
/**
* Create an OffsetOption from tail N messages.
*
* @param tailN - Number of messages from the tail (must be >= 0)
* @return OffsetOption instance
* @throws Error if tailN is negative
*/
static ofTailN(tailN: number | bigint): OffsetOption;
/**
* Create an OffsetOption from a timestamp.
*
* @param timestamp - Unix timestamp in milliseconds (must be >= 0)
* @return OffsetOption instance
* @throws Error if timestamp is negative
*/
static ofTimestamp(timestamp: number | bigint): OffsetOption;
/**
* Get the type of this OffsetOption.
*
* @return OffsetType
*/
getType(): OffsetType;
/**
* Get the value of this OffsetOption.
*
* @return Value as bigint
*/
getValue(): bigint;
/**
* Returns a string representation of this OffsetOption.
*
* @return String representation
*/
toString(): string;
/**
* Validate that a bigint value is within the safe number range.
*
* @param value - The bigint value to validate
* @throws Error if value is out of safe number range
*/
private validateSafeNumberRange;
/**
* Convert this OffsetOption to ProtoBuf OffsetOption.
*
* @return ProtoBuf OffsetOption instance
*/
toProtobuf(): ProtoOffsetOption;
equals(other: OffsetOption): boolean;
hashCode(): number;
}