-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add documentation and debug connection issue
Signed-off-by: nyagamunene <[email protected]>
- Loading branch information
1 parent
a67b93e
commit 7377a6d
Showing
7 changed files
with
120 additions
and
60 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
# Propellerd Build | ||
build | ||
config.toml |
This file was deleted.
Oops, something went wrong.
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,87 @@ | ||
# Proxy Service | ||
|
||
The Proxy Service acts as a bridge between MQTT and HTTP protocols in the Propeller system. It enables bidirectional communication between MQTT clients and HTTP endpoints, allowing for seamless integration of different protocols. | ||
|
||
## Overview | ||
|
||
The proxy service performs two main functions: | ||
1. Subscribes to MQTT topics and forwards messages to HTTP endpoints | ||
2. Streams data between MQTT and HTTP protocols | ||
|
||
## Configuration | ||
|
||
The service is configured using environment variables. | ||
|
||
### Environment Variables | ||
|
||
#### MQTT Configuration | ||
|
||
| Variable | Description | Default | Required | | ||
|----------|-------------|---------|----------| | ||
| `BrokerURL` | URL of the MQTT broker | `localhost:1883` | Yes | | ||
| `PropletID` | Unique identifier for the proplet | `72fd490b-f91f-47dc-aa0b-a65931719ee1` | Yes | | ||
| `ChannelID` | Channel identifier for MQTT communication | `cb6cb9ae-ddcf-41ab-8f32-f3e93b3a3be2` | Yes | | ||
| `PropletPassword` | Password for MQTT authentication | `3963a940-332e-4a18-aa57-bab4d4124ab0` | Yes | | ||
|
||
#### Registry Configuration | ||
|
||
| Variable | Description | Default | Required | | ||
|----------|-------------|---------|----------| | ||
| `RegistryURL` | URL of the HTTP registry | `localhost:5000` | Yes | | ||
| `Authenticate` | Enable/disable registry authentication | `false` | No | | ||
| `RegistryUsername` | Username for registry authentication | `""` | Only if `Authenticate=true` | | ||
| `RegistryPassword` | Password for registry authentication | `""` | Only if `Authenticate=true` | | ||
|
||
### Example Configuration | ||
```env | ||
# MQTT Configuration | ||
BrokerURL=localhost:1883 | ||
PropletID=72fd490b-f91f-47dc-aa0b-a65931719ee1 | ||
ChannelID=cb6cb9ae-ddcf-41ab-8f32-f3e93b3a3be2 | ||
PropletPassword=3963a940-332e-4a18-aa57-bab4d4124ab0 | ||
# Registry Configuration | ||
RegistryURL=localhost:5000 | ||
Authenticate=false | ||
RegistryUsername= | ||
RegistryPassword= | ||
``` | ||
|
||
## Running the Service | ||
|
||
The proxy service can be started by running the main.go file: | ||
|
||
```bash | ||
go run cmd/proxy/main.go | ||
``` | ||
|
||
## Service Flow | ||
|
||
1. **Initialization** | ||
- Loads configuration from environment variables | ||
- Sets up logging | ||
- Creates a new proxy service instance | ||
|
||
2. **Connection** | ||
- Establishes connection to the MQTT broker | ||
- Subscribes to configured topics | ||
- Sets up HTTP streaming | ||
|
||
3. **Operation** | ||
- Runs two concurrent streams: | ||
- StreamHTTP: Handles HTTP communication | ||
- StreamMQTT: Handles MQTT communication | ||
- Uses error groups for graceful error handling and shutdown | ||
|
||
4. **Error Handling** | ||
- Implements comprehensive error logging | ||
- Graceful shutdown with proper resource cleanup | ||
- Automatic disconnection from MQTT broker on service termination | ||
|
||
## HTTP Registry Operations | ||
|
||
The HTTP configuration supports: | ||
- Registry operations with optional authentication | ||
- Automatic retry mechanism for failed requests | ||
- Chunked data handling with configurable chunk size (1MB default) | ||
- Static credential caching for authenticated requests |
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 |
---|---|---|
@@ -1,21 +1,8 @@ | ||
package config | ||
|
||
import ( | ||
"github.com/caarlos0/env/v11" | ||
) | ||
|
||
type MQTTProxyConfig struct { | ||
BrokerURL string `env:"BROKER_URL" envDefault:""` | ||
Password string `env:"PASSWORD" envDefault:""` | ||
PropletID string `env:"PROPLET_ID" envDefault:""` | ||
ChannelID string `env:"CHANNEL_ID" envDefault:""` | ||
} | ||
|
||
func LoadMQTTConfig(opts env.Options) (*MQTTProxyConfig, error) { | ||
c := MQTTProxyConfig{} | ||
if err := env.ParseWithOptions(&c, opts); err != nil { | ||
return nil, err | ||
} | ||
|
||
return &c, nil | ||
BrokerURL string | ||
Password string | ||
PropletID string | ||
ChannelID string | ||
} |
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