114 lines
4.7 KiB
Markdown
114 lines
4.7 KiB
Markdown
# jeb Utils
|
|
|
|
Common utils for JEB client and server.
|
|
|
|
## Installation
|
|
You can install the library using `pip`:
|
|
|
|
```bash
|
|
pip install jeb-utils --index-url https://repo.jcloud-services.ddns.net/simple/ --extra-index-url https://pypi.org/simple/
|
|
```
|
|
|
|
## Functions and classes
|
|
### `auth_utils`: Utilities for the jeb authentication
|
|
- `load_cert_file`: Loads a certificate from a file
|
|
- `Identity`: An identity, based on a certificate
|
|
- `Verifier`: A verifier for the CA of an identity.
|
|
|
|
### `crypto_utils`: Utilities for cryptography
|
|
- `generate_keypair`: Generates a private and a public key
|
|
- `serialize_public_key`: Serializes a public key to bytes.
|
|
- `deserialize_public_key`: Deserializes a public key from bytes.
|
|
- `derive_aes_key`: Derives an AES key from a private key and the peer public key.
|
|
|
|
### `exceptions`: Common exceptions of the jeb library and server
|
|
- `UnknownProtocolError`: The protocol is unknown.
|
|
- `ProtocolSyntaxError`: The syntax is not valid for the protocol.
|
|
- `CRCInvalidError`: The CRC is invalid.
|
|
- `UnknownCreationError`: Unknown error creating an object.
|
|
- `UnknownSubscribingError`: Unknown error subscribing topics.
|
|
- `UnknownUnsubscribingError`: Unknown error unsubscribing topics.
|
|
- `TopicNotFoundError`: The topic was not found.
|
|
- `TopicExistsError`: The topic already exists.
|
|
- `TopicPartitionExistsError`: The partition of the topic already exists.
|
|
- `TopicPartitionNotFoundError`: The partition of the topic was not found.
|
|
- `TopicNotSubscribedError`: The topic is not subscribed.
|
|
- `InvalidTopicNameError`: The topic name is invalid.
|
|
- `FetchStartOutOfRangeError`: The fetch start is out of range.
|
|
- `FormatError`: The format is invalid.
|
|
- `CertificateNotTrustedError`: The certificate is not trusted.
|
|
|
|
### `jeb_utils`: Functions for jeb actions
|
|
- `format_topic_partitions`: Formats the topic partitions.
|
|
- `mktopic`: Creates a topic.
|
|
- `rmtopic`: Removes a topic.
|
|
- `mktopicpart`: Creates a partition of a topic.
|
|
- `rmtopicpart`: Removes a partition of a topic.
|
|
- `get_topics`: Returns all topics.
|
|
- `get_segment_base_timestamp`: Returns the base timestamp of a segment.
|
|
- `get_log_end_offsets`: Gets the end offsets.
|
|
- `init`: Initializes the module.
|
|
- `validate_topic_partition`: Validates a topic partition number format.
|
|
- `validate_topic_name`: Validates a topic name.
|
|
- `check_topic_exists`: Checks whether a topic exists.
|
|
- `pack_record_headers`: Packs the record header dictionary into bytes.
|
|
- `unpack_record_headers`: Unpacks the record headers from bytes.
|
|
- `create_record`: Creates a record.
|
|
- `fetch_records`: Fetches records from the topic.
|
|
- `Topic`: A topic.
|
|
- `Segment`: A segment of a topic.
|
|
- `FileCorruptWarning`: A warning for corrupt log files.
|
|
- `AttributesByte`: An attributes byte of a record.
|
|
|
|
### `jebp_utils`: Utilities for the jeb protocol
|
|
- `MessageFormatError`: If the message format is invalid.
|
|
- `sendmsg`: Sends a message.
|
|
- `readmsg`: Receives a message.
|
|
- `pack_fields`: Packs the fields into a compact bytestring.
|
|
- `unpack_fields`: Unpacks the field from a bytestring.
|
|
|
|
### `utils`: General utilities
|
|
- `is_number`: Checks whether the string is a number.
|
|
- `int_to_bytes`: Converts the integer into bytes (dynamic length).
|
|
- `bits_to_byte`: Converts the bits into a single byte.
|
|
- `byte_to_bits`: Converts the byte to a tuple of bits.
|
|
- `get_next_lower_integer_multiple`: Returns the next lower integer multiple.
|
|
- `find_nearest_lower_number`: Finds the nearest lower number to the target from the list.
|
|
- `create_file_if_not_exists`: Creates a file if it does not exist.
|
|
|
|
## Changelog
|
|
### Version 0.2.4
|
|
- Add support for `signed=True` in `jeb_utils.utils.int_to_bytes`
|
|
|
|
### Version 0.2.3
|
|
- Bug fix: `is_valid_host`, `is_valid_port` and `validate_address_port` in `jeb_utils.utils` were not included in `__all__`
|
|
|
|
### Version 0.2.2
|
|
- Bug fix: jeb_utils.utils.is_number could return `True` even if the base is `0` which is mathematically incorrect.
|
|
|
|
### Version 0.2.1
|
|
- Add feature for validating addresses.
|
|
|
|
### Version 0.2.0
|
|
- Remove all the functions and classes that are now in jeb-server-utils.
|
|
|
|
### Version 0.1.4
|
|
- Bug fix: Due to a refactoring, `jeb_utils.jebp_utils.unpack_fields` did not work.
|
|
|
|
### Version 0.1.3
|
|
- Fatal bug fix: `jeb_utils.jeb_utils.validate_topic_name` has not returned `True` if the topic name is valid, it returned `None` (falsy). Now it returns `True` if the topic name is valid.
|
|
|
|
### Version 0.1.2
|
|
- Bug fix: `jeb_utils.mktopicpart` has tried to raise `jeb_utils.exceptions.exceptions.TopicNotFoundError` instead of `jeb_utils.exceptions.TopicNotFoundError` if the topic does not exist.
|
|
|
|
### Version 0.1.1
|
|
- Support for custom data paths (`jeb_utils.init`)
|
|
|
|
### Version 0.1.0
|
|
- First release
|
|
- `auth_utils`
|
|
- `crypto_utils`
|
|
- `exceptions`
|
|
- `jeb_utils`
|
|
- `jebp_utils`
|
|
- `utils` |