Skip to content
This repository has been archived by the owner on May 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #77 from Regner/general-tweaks
Browse files Browse the repository at this point in the history
Some general tweaks
  • Loading branch information
regner authored Aug 19, 2017
2 parents 4f27b0e + d62af12 commit 5d73a8f
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion client/operation_auction_get_offers.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ func (op operationAuctionGetOffersResponse) Process(state *albionState, uploader
return
}

uploader.sendToIngest(data, "marketorders")
uploader.sendToIngest(data, lib.MarketOrdersIngest)
}
2 changes: 1 addition & 1 deletion client/operation_auction_get_requests.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func (op operationAuctionGetRequestsResponse) Process(state *albionState, upload
return
}

uploader.sendToIngest(data, "marketorders")
uploader.sendToIngest(data, lib.MarketOrdersIngest)
}
13 changes: 9 additions & 4 deletions client/operation_gold_market_get_average_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package client
import (
"encoding/json"

"github.com/regner/albiondata-client/lib"
"github.com/regner/albiondata-client/log"
)

Expand All @@ -14,18 +15,22 @@ func (op operationGoldMarketGetAverageInfo) Process(state *albionState, uploader
}

type operationGoldMarketGetAverageInfoResponse struct {
GoldPrices []int `mapstructure:"0" json:"prices"`
TimeStamps []int `mapstructure:"1" json:"timestamps"`
GoldPrices []int `mapstructure:"0"`
TimeStamps []int `mapstructure:"1"`
}

func (op operationGoldMarketGetAverageInfoResponse) Process(state *albionState, uploader iuploader) {
log.Debug("Got response to GoldMarketGetAverageInfo operation...")

data, err := json.Marshal(op)
data, err := json.Marshal(lib.GoldPricesUpload{
Prices: op.GoldPrices,
TimeStamps: op.TimeStamps,
})

if err != nil {
log.Errorf("Error while marshalling payload for gold prices: %v", err)
return
}

uploader.sendToIngest(data, "goldprices")
uploader.sendToIngest(data, lib.GoldPricesIngest)
}
4 changes: 1 addition & 3 deletions client/uploader_nats.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ func newNATSUploader(url string) iuploader {
}

func (u *natsUploader) sendToIngest(body []byte, queue string) {
rawQueue := queue + ".ingest"

if err := u.nc.Publish(rawQueue, body); err != nil {
if err := u.nc.Publish(queue, body); err != nil {
log.Errorf("Error while sending ingest to nats with data: %v", err)
}
}
2 changes: 1 addition & 1 deletion cmd/albiondata-client/albiondata-client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ func init() {
flag.StringVar(
&client.ConfigGlobal.IngestBaseUrl,
"i",
"nats://ingest.albion-data.com:4222/",
"nats://public:notsecure@ingest.albion-data.com:4222/",
"Base URL to send data to, can be 'nats://', 'http://' and can have multiple uploaders comma separated.",
)

Expand Down
6 changes: 3 additions & 3 deletions cmd/natsdumper/natsdumper.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ func init() {
flag.StringVar(
&natsURL,
"i",
"nats://ingest.albion-data.com:4222",
"NATS URL to subscribe to.",
"nats://public:notsecure@ingest.albion-data.com:4222",
"NATS URL to connect to.",
)
}

Expand All @@ -39,7 +39,7 @@ func main() {
defer nc.Close()

marketCh := make(chan *nats.Msg, 64)
marketSub, err := nc.ChanSubscribe("marketorders.ingest", marketCh)
marketSub, err := nc.ChanSubscribe(lib.GoldPricesDeduped, marketCh)
if err != nil {
fmt.Printf("%v\n", err)
return
Expand Down
8 changes: 4 additions & 4 deletions lib/gold.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package lib

// GoldInfoUpload contains the current gold prices
type GoldInfoUpload struct {
Prices []int `json:"prices"`
TimeStamps []int `json:"timestamps"`
// GoldPricesUpload contains the current gold prices
type GoldPricesUpload struct {
Prices []int `json:"Prices"`
TimeStamps []int `json:"Timestamps"`
}
8 changes: 8 additions & 0 deletions lib/nats.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package lib

const (
GoldPricesIngest = "goldprices.ingest"
GoldPricesDeduped = "goldprices.deduped"
MarketOrdersIngest = "marketorders.ingest"
MarketOrdersDeduped = "marketorders.deduped"
)
2 changes: 1 addition & 1 deletion pkg/nsis/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
TOP_SRCDIR = ../..
PACKAGE = albiondata-client
PACKAGE_NAME = AlbionData Client
PACKAGE_NAME = Albion Data Client
PACKAGE_BUGREPORT = https://github.com/Regner/albiondata-client/issues
INSTALLER_COMPRESSION = lzma
PACKAGE_EXE = albiondata-client.exe
Expand Down

0 comments on commit 5d73a8f

Please sign in to comment.