This tool provides interaction with energy consumption data from Poland's Central Statistical Office (GUS) provided by API DBW, created also by GUS.
- Decoding data returned from API DBW
- Sorting results by region name
- Filtering results with region name and character
- Displaying results in custom CLI
- Serving API over TLS
- Routing gRPC-web requests directly to gRPC Go Server
- More filtering parameters
- Stats for eco power sources
Client CLI: Go + urfave cli v2
Server: Go + gRPC
Make sure you have installed Go. Next configure Go paths in your profile files.
export GOPATH=$HOME/go
export PATH=$PATH:$GOPATH/bin
export PATH=$PATH:$GOPATH/bin:/usr/local/go/bin
Verify path by following command (if path contains above paths everything is fine)
$GOPATHCheck your enviromental variable
$env:GOPATHIf everything is ok you should get the following path in you console
C:\Users\[username]\goAdd the workspace’s bin subdirectory to your $PATH. You can do this using the setx command in PowerShell
setx PATH "$($env:path);$GOPATH\bin"Change directory to main folder solarenergy and then build image
docker build --pull --rm -f "Dockerfile" -t solarenergy:latest "." Clone repository to your local folder
git clone https://github.com/Bialson/solarenergy.gitYour folder structure will be looking like this
.
└── solarenergy/
├── proto/
│ ├── energy_grpc.pb.go
│ ├── energy.pb.go
│ └── energy.proto
├── solarenergy-cli/
│ ├── bin/
│ │ └── solarenergy-cli
│ ├── main.go
│ └── service.go
├── solarenergy-server/
│ ├── bin/
│ │ └── solarenergy-server
│ │── gRPC_classic/
│ │ └── main.go
│ │── gRPC_web/
│ │ └── main.go
│ ├── service_test.go
│ ├── service.go
│ ├── test_server.go
│ ├── tools.go
│ ├── variables.go
│ └── web_tls.go
├── .gitignore
├── Dockerfile
├── go.mod
├── go.sum
├── Makefile
├── README.md
└── run.sh
To install client and server CLI change directory to solarenergy-cli and solarenergy-server folders and run go install command in each folder
cd solarenergy-cli
go install
cd ../solarenergy-server
go installNote Package provides builded files ready to install, if you want to add some changes and then rebuild the preffered CLI, run
go build -o bin/[file_name]command in it's folder.
solarenergy-serverOn your you will be receiving log's from server, request, response status.
solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER -a AMOUNT_VALUEIf you run solarenergy-cli command without params, you should see help page with all params supported by this command.
cd solarenergy-server
go test docker run --rm -it solarenergy:latest Note If you don't provide any optional params, data request will be executed with default values
| Parameter | Type | Value |
|---|---|---|
Year |
int |
2020 |
Response amount |
int |
0 |
Region |
string |
"" |
Region character |
string |
"" |
solarenergy-cli gp -y YEAR_VALUE| Parameter | Type | Description |
|---|---|---|
get-power, gp |
string |
Required. Get power consumption command |
--year, -y |
int |
Optional. Get power consumption from given year |
solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME| Parameter | Type | Description |
|---|---|---|
--year, -y |
int |
Optional. Get power consumption from given year |
--region, -r |
string |
Optional. Precise power consumption by region |
solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER| Parameter | Type | Description |
|---|---|---|
--year, -y |
int |
Optional. Get power consumption from given year |
--region, -r |
string |
Optional. Precise power consumption by region |
--character, -ch |
string |
Optional. Precise power consumption by region character |
solarenergy-cli gp -y YEAR_VALUE -r REGION_NAME -ch REGION_CHARACTER -a AMOUNT_VALUE| Parameter | Type | Description |
|---|---|---|
--year, -y |
string |
Optional. Get power consumption from given year |
--region, -r |
string |
Optional. Precise power consumption by region |
--character, -ch |
string |
Optional. Precise power consumption by region character |
--amount, -a |
int |
Optional. Limit power consumption records |
| Parameter | Type | Value |
|---|---|---|
Year |
int |
<2000; 2020> |
Response amount |
int |
<0; 204> |
Region |
string |
POLSKA MAŁOPOLSKIE ŚLĄSKIE LUBUSKIE WIELKOPOLSKIE ZACHODNIOPOMORSKIE DOLNOŚLĄSKIE OPOLSKIE KUJAWSKO-POMORSKIE POMORSKIE WARMIŃSKO-MAZURSKIE ŁÓDZKIE ŚWIĘTOKRZYSKIE LUBELSKIE PODKARPACKIE PODLASKIE MAZOWIECKIE |
Region character |
string |
Ogółem Miasto Wieś |