-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1ed7ac4
commit 3c9bf01
Showing
16 changed files
with
657 additions
and
110 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -253,6 +253,7 @@ hardcoded | |
hashable | ||
hashmap | ||
hasnull | ||
healthz | ||
hostname | ||
html | ||
hudi | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import os | ||
from datetime import datetime | ||
|
||
from fennel.testing import mock | ||
|
||
__owner__ = "[email protected]" | ||
|
||
|
||
@mock | ||
def test_http_sink(client): | ||
os.environ["KAFKA_USERNAME"] = "test" | ||
os.environ["KAFKA_PASSWORD"] = "test" | ||
os.environ["SNOWFLAKE_USERNAME"] = "some-name" | ||
os.environ["SNOWFLAKE_PASSWORD"] = "some-password" | ||
os.environ["DB_NAME"] = "some-db-name" | ||
|
||
from fennel.connectors import source, Kafka | ||
from fennel.datasets import dataset, field | ||
|
||
kafka = Kafka( | ||
name="my_kafka", | ||
bootstrap_servers="localhost:9092", # could come via os env var too | ||
security_protocol="SASL_PLAINTEXT", | ||
sasl_mechanism="PLAIN", | ||
sasl_plain_username=os.environ["KAFKA_USERNAME"], | ||
sasl_plain_password=os.environ["KAFKA_PASSWORD"], | ||
) | ||
|
||
# docsnip-highlight next-line | ||
@source(kafka.topic("user", format="json"), disorder="14d", cdc="upsert") | ||
@dataset | ||
class SomeDataset: | ||
uid: int = field(key=True) | ||
email: str | ||
timestamp: datetime | ||
|
||
from fennel.connectors import source, Kafka | ||
from fennel.datasets import dataset, field, pipeline, Dataset | ||
from fennel.lib.params import inputs | ||
|
||
# docsnip basic | ||
from fennel.connectors import sink, HTTP | ||
|
||
# docsnip-highlight start | ||
http = HTTP( | ||
name="http", | ||
host="http://http-echo-server.harsha.svc.cluster.local:8081/", | ||
healthz="/health", | ||
) | ||
# docsnip-highlight end | ||
|
||
@dataset | ||
# docsnip-highlight start | ||
@sink( | ||
http.path(endpoint="/sink", limit=1000, headers={"Foo": "Bar"}), | ||
cdc="debezium", | ||
how="incremental", | ||
) | ||
# docsnip-highlight end | ||
class SomeDatasetFiltered: | ||
uid: int = field(key=True) | ||
email: str | ||
timestamp: datetime | ||
|
||
@pipeline | ||
@inputs(SomeDataset) | ||
def gmail_filtered(cls, dataset: Dataset): | ||
return dataset.filter( | ||
lambda row: row["email"].contains("gmail.com") | ||
) | ||
|
||
# /docsnip | ||
|
||
client.commit( | ||
message="some commit msg", datasets=[SomeDataset, SomeDatasetFiltered] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: HTTP | ||
order: 0 | ||
status: published | ||
--- | ||
### HTTP | ||
Data sink to HTTP endpoints. | ||
|
||
#### Connector Parameters | ||
<Expandable title="name" type="str"> | ||
A name to identify the sink. The name should be unique across all Fennel connectors. | ||
</Expandable> | ||
|
||
<Expandable title="host" type="str|Secret"> | ||
The HTTP host URL. Example: https://127.0.0.1:8081 | ||
</Expandable> | ||
|
||
<Expandable title="healthz" type="str"> | ||
The health check endpoint to verify the server's availability. | ||
</Expandable> | ||
|
||
#### HTTP Path Parameters | ||
<Expandable title="endpoint" type="str"> | ||
The specific endpoint where data will be sent | ||
</Expandable> | ||
|
||
<Expandable title="limit" type="Optional[int]"> | ||
The number of records to include in each request to the endpoint. Default: 100 | ||
</Expandable> | ||
|
||
<Expandable title="headers" type="Dict[str,str]"> | ||
A map of headers to include with each request | ||
</Expandable> | ||
|
||
|
||
<pre snippet="api-reference/sinks/http_sink#basic" | ||
status="success" message="HTTP sink"> | ||
</pre> | ||
|
||
#### Errors | ||
<Expandable title="Connectivity Issues"> | ||
Fennel tries to test the connection with your HTTP sink during `commit` itself | ||
using the health check endpoint | ||
|
||
Note: Mock client can not talk to any external data sink and hence is unable to | ||
do this validation at commit time. | ||
</Expandable> | ||
|
||
:::info | ||
- HTTP sink ensures at least once delivery. To handle duplicates, use | ||
`["payload"]["source"]["fennel"]["partition"]` and `["payload"]["source"]["fennel"]["offset"]` | ||
fields in the output. | ||
::: | ||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.