Skip to content

Commit 7421bc8

Browse files
docs: add elasticsearch examples, expand postgres/configs docs, and refine api references
- Add new elasticsearch adapter example (1100 lines) - Expand postgres adapter examples significantly - Update api_reference for adapters, configs, helpers, models, and utils - Add config_management examples and update installation/usage guides - Remove unused pyproject.toml entry and sync uv.lock
1 parent db91704 commit 7421bc8

30 files changed

Lines changed: 2413 additions & 847 deletions

.env.example

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,6 @@ KAFKA__MAX_PARTITION_FETCH_BYTES=1048576
178178
KAFKA__QUEUE_BUFFERING_MAX_MESSAGES=100000
179179
KAFKA__STATISTICS_INTERVAL_MS=0
180180

181-
# Kavenegar Configuration
182-
KAVENEGAR__SERVER_URL=
183-
KAVENEGAR__API_KEY=
184-
KAVENEGAR__PHONE_NUMBER=
185-
186181
# Keycloak Configuration
187182
KEYCLOAK__SERVER_URL=
188183
KEYCLOAK__CLIENT_ID=

archipy/configs/base_config.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
FileConfig,
1919
GrpcConfig,
2020
KafkaConfig,
21-
KavenegarConfig,
2221
KeycloakConfig,
2322
MinioConfig,
2423
ParsianShaparakConfig,
@@ -73,7 +72,6 @@ class BaseConfig[R](BaseSettings):
7372
FILE (FileConfig): File handling configuration
7473
GRPC (GrpcConfig): gRPC service configuration
7574
KAFKA (KafkaConfig): Kafka integration configuration
76-
KAVENEGAR (KavenegarConfig): Kavenegar SMS service configuration
7775
KEYCLOAK (KeycloakConfig): Keycloak integration configuration
7876
MINIO (MinioConfig): MinIO object storage configuration
7977
PARSIAN_SHAPARAK (ParsianShaparakConfig): Parsian Shaparak payment gateway configuration
@@ -162,7 +160,6 @@ def settings_customise_sources(
162160
FILE: FileConfig = FileConfig()
163161
GRPC: GrpcConfig = GrpcConfig()
164162
KAFKA: KafkaConfig = KafkaConfig()
165-
KAVENEGAR: KavenegarConfig = KavenegarConfig()
166163
KEYCLOAK: KeycloakConfig = KeycloakConfig()
167164
MINIO: MinioConfig = MinioConfig()
168165
PARSIAN_SHAPARAK: ParsianShaparakConfig = ParsianShaparakConfig()

archipy/configs/config_template.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ElasticsearchConfig(BaseModel):
4949
RETRY_ON_TIMEOUT: bool = Field(default=True, description="Retry on connection timeouts")
5050
RETRY_ON_STATUS: tuple[int, ...] = Field(default=(429, 502, 503, 504), description="HTTP status codes to retry on")
5151
IGNORE_STATUS: tuple[int, ...] = Field(default=(), description="HTTP status codes to ignore as errors")
52-
SNIFF_ON_START: bool = Field(default=False, description="Sniff nodes on client instantiation")
52+
SNIFF_ON_START: bool = Field(default=True, description="Sniff nodes on client instantiation")
5353
SNIFF_BEFORE_REQUESTS: bool = Field(default=False, description="Sniff nodes before requests")
5454
SNIFF_ON_NODE_FAILURE: bool = Field(default=True, description="Sniff nodes on node failure")
5555
MIN_DELAY_BETWEEN_SNIFFING: float = Field(
@@ -653,18 +653,6 @@ class SentryConfig(BaseModel):
653653
TRACES_SAMPLE_RATE: float = Field(default=0.0, description="Performance monitoring sampling rate (0.0 to 1.0)")
654654

655655

656-
class KavenegarConfig(BaseModel):
657-
"""Configuration settings for Kavenegar SMS service integration.
658-
659-
Controls connection parameters and authentication for sending SMS messages
660-
through the Kavenegar service.
661-
"""
662-
663-
SERVER_URL: str | None = Field(default=None, description="Kavenegar API server URL")
664-
API_KEY: str | None = Field(default=None, description="Kavenegar API key")
665-
PHONE_NUMBER: str | None = Field(default=None, description="Default sender phone number")
666-
667-
668656
class AuthConfig(BaseModel):
669657
"""Configuration settings for authentication and security.
670658

docs/api_reference/adapters.md

Lines changed: 122 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,24 @@ type has its own dedicated adapter implementation.
2222
The base SQLAlchemy components provide the core functionality used by all database-specific adapters:
2323

2424
::: archipy.adapters.base.sqlalchemy.adapters
25-
options:
26-
show_root_heading: true
27-
show_source: true
25+
options:
26+
show_root_heading: true
27+
show_source: true
2828

2929
::: archipy.adapters.base.sqlalchemy.ports
30-
options:
31-
show_root_heading: true
32-
show_source: true
30+
options:
31+
show_root_heading: true
32+
show_source: true
3333

3434
::: archipy.adapters.base.sqlalchemy.session_managers
35-
options:
36-
show_root_heading: true
37-
show_source: true
35+
options:
36+
show_root_heading: true
37+
show_source: true
3838

3939
::: archipy.adapters.base.sqlalchemy.session_manager_registry
40-
options:
41-
show_root_heading: true
42-
show_source: true
40+
options:
41+
show_root_heading: true
42+
show_source: true
4343

4444
#### PostgreSQL
4545

@@ -56,19 +56,19 @@ users = orm_adapter.query(User).filter(User.active == True).all()
5656
```
5757

5858
::: archipy.adapters.postgres.sqlalchemy.adapters
59-
options:
60-
show_root_heading: true
61-
show_source: true
59+
options:
60+
show_root_heading: true
61+
show_source: true
6262

6363
::: archipy.adapters.postgres.sqlalchemy.session_managers
64-
options:
65-
show_root_heading: true
66-
show_source: true
64+
options:
65+
show_root_heading: true
66+
show_source: true
6767

6868
::: archipy.adapters.postgres.sqlalchemy.session_manager_registry
69-
options:
70-
show_root_heading: true
71-
show_source: true
69+
options:
70+
show_root_heading: true
71+
show_source: true
7272

7373
#### SQLite
7474

@@ -82,19 +82,19 @@ orm_adapter = SQLiteSQLAlchemyAdapter()
8282
```
8383

8484
::: archipy.adapters.sqlite.sqlalchemy.adapters
85-
options:
86-
show_root_heading: true
87-
show_source: true
85+
options:
86+
show_root_heading: true
87+
show_source: true
8888

8989
::: archipy.adapters.sqlite.sqlalchemy.session_managers
90-
options:
91-
show_root_heading: true
92-
show_source: true
90+
options:
91+
show_root_heading: true
92+
show_source: true
9393

9494
::: archipy.adapters.sqlite.sqlalchemy.session_manager_registry
95-
options:
96-
show_root_heading: true
97-
show_source: true
95+
options:
96+
show_root_heading: true
97+
show_source: true
9898

9999
#### StarRocks
100100

@@ -108,19 +108,19 @@ orm_adapter = StarrocksSQLAlchemyAdapter()
108108
```
109109

110110
::: archipy.adapters.starrocks.sqlalchemy.adapters
111-
options:
112-
show_root_heading: true
113-
show_source: true
111+
options:
112+
show_root_heading: true
113+
show_source: true
114114

115115
::: archipy.adapters.starrocks.sqlalchemy.session_managers
116-
options:
117-
show_root_heading: true
118-
show_source: true
116+
options:
117+
show_root_heading: true
118+
show_source: true
119119

120120
::: archipy.adapters.starrocks.sqlalchemy.session_manager_registry
121-
options:
122-
show_root_heading: true
123-
show_source: true
121+
options:
122+
show_root_heading: true
123+
show_source: true
124124

125125
#### ScyllaDB
126126

@@ -155,14 +155,46 @@ users = adapter.select("users", conditions={"id": 1})
155155
For detailed examples and usage guidelines, see the [ScyllaDB Adapter Examples](../examples/adapters/scylladb.md).
156156

157157
::: archipy.adapters.scylladb.adapters
158-
options:
159-
show_root_heading: true
160-
show_source: true
158+
options:
159+
show_root_heading: true
160+
show_source: true
161161

162162
::: archipy.adapters.scylladb.ports
163-
options:
164-
show_root_heading: true
165-
show_source: true
163+
options:
164+
show_root_heading: true
165+
show_source: true
166+
167+
### Elasticsearch
168+
169+
Full-text search and analytics adapter with sync and async support.
170+
171+
```python
172+
from archipy.adapters.elasticsearch.adapters import ElasticsearchAdapter, AsyncElasticsearchAdapter
173+
174+
# Create a sync adapter (uses global config)
175+
es = ElasticsearchAdapter()
176+
177+
# Ping the cluster
178+
alive = es.ping()
179+
180+
# Index a document
181+
es.index(index="articles", document={"title": "Hello World"}, doc_id="doc-1")
182+
183+
# Search
184+
results = es.search(index="articles", query={"query": {"match_all": {}}})
185+
```
186+
187+
For detailed examples and usage guidelines, see the [Elasticsearch Adapter Examples](../examples/adapters/elasticsearch.md).
188+
189+
::: archipy.adapters.elasticsearch.adapters
190+
options:
191+
show_root_heading: true
192+
show_source: true
193+
194+
::: archipy.adapters.elasticsearch.ports
195+
options:
196+
show_root_heading: true
197+
show_source: true
166198

167199
### Email
168200

@@ -183,14 +215,14 @@ email_adapter.send_email(
183215
```
184216

185217
::: archipy.adapters.email.adapters
186-
options:
187-
show_root_heading: true
188-
show_source: true
218+
options:
219+
show_root_heading: true
220+
show_source: true
189221

190222
::: archipy.adapters.email.ports
191-
options:
192-
show_root_heading: true
193-
show_source: true
223+
options:
224+
show_root_heading: true
225+
show_source: true
194226

195227
### Keycloak
196228

@@ -232,14 +264,14 @@ user_info = asyncio.run(auth_example())
232264
For detailed examples and usage guidelines, see the [Keycloak Adapter Examples](../examples/adapters/keycloak.md).
233265

234266
::: archipy.adapters.keycloak.adapters
235-
options:
236-
show_root_heading: true
237-
show_source: true
267+
options:
268+
show_root_heading: true
269+
show_source: true
238270

239271
::: archipy.adapters.keycloak.ports
240-
options:
241-
show_root_heading: true
242-
show_source: true
272+
options:
273+
show_root_heading: true
274+
show_source: true
243275

244276
### MinIO
245277

@@ -265,14 +297,14 @@ download_url = minio.presigned_get_object("my-bucket", "document.pdf")
265297
For detailed examples and usage guidelines, see the [MinIO Adapter Examples](../examples/adapters/minio.md).
266298

267299
::: archipy.adapters.minio.adapters
268-
options:
269-
show_root_heading: true
270-
show_source: true
300+
options:
301+
show_root_heading: true
302+
show_source: true
271303

272304
::: archipy.adapters.minio.ports
273-
options:
274-
show_root_heading: true
275-
show_source: true
305+
options:
306+
show_root_heading: true
307+
show_source: true
276308

277309
### Redis
278310

@@ -286,14 +318,14 @@ redis = RedisAdapter()
286318
```
287319

288320
::: archipy.adapters.redis.adapters
289-
options:
290-
show_root_heading: true
291-
show_source: true
321+
options:
322+
show_root_heading: true
323+
show_source: true
292324

293325
::: archipy.adapters.redis.ports
294-
options:
295-
show_root_heading: true
296-
show_source: true
326+
options:
327+
show_root_heading: true
328+
show_source: true
297329

298330
### Kafka
299331

@@ -319,14 +351,14 @@ kafka.consume("my-topic", process_message)
319351
For detailed examples and usage guidelines, see the [Kafka Adapter Examples](../examples/adapters/kafka.md).
320352

321353
::: archipy.adapters.kafka.adapters
322-
options:
323-
show_root_heading: true
324-
show_source: true
354+
options:
355+
show_root_heading: true
356+
show_source: true
325357

326358
::: archipy.adapters.kafka.ports
327-
options:
328-
show_root_heading: true
329-
show_source: true
359+
options:
360+
show_root_heading: true
361+
show_source: true
330362

331363
### Payment Gateways
332364

@@ -364,9 +396,9 @@ if payment_response.status == 0: # 0 means success
364396
For detailed examples and usage guidelines, see the [Parsian Payment Gateway Examples](../examples/adapters/parsian_payment.md).
365397

366398
::: archipy.adapters.internet_payment_gateways.ir.parsian.adapters
367-
options:
368-
show_root_heading: true
369-
show_source: true
399+
options:
400+
show_root_heading: true
401+
show_source: true
370402

371403
### Temporal {#temporal}
372404

@@ -425,27 +457,27 @@ For detailed examples and usage guidelines, see the [Temporal Examples](../examp
425457
#### Temporal Adapter
426458

427459
::: archipy.adapters.temporal.adapters
428-
options:
429-
show_root_heading: true
430-
show_source: true
460+
options:
461+
show_root_heading: true
462+
show_source: true
431463

432464
#### Temporal Ports
433465

434466
::: archipy.adapters.temporal.ports
435-
options:
436-
show_root_heading: true
437-
show_source: true
467+
options:
468+
show_root_heading: true
469+
show_source: true
438470

439471
#### Temporal Worker Manager
440472

441473
::: archipy.adapters.temporal.worker
442-
options:
443-
show_root_heading: true
444-
show_source: true
474+
options:
475+
show_root_heading: true
476+
show_source: true
445477

446478
#### Temporal Base Classes
447479

448480
::: archipy.adapters.temporal.base
449-
options:
450-
show_root_heading: true
451-
show_source: true
481+
options:
482+
show_root_heading: true
483+
show_source: true

0 commit comments

Comments
 (0)