refactor: Update config.dev.toml and sub.go for Hasura integration

The code changes in config.dev.toml and sub.go update the configuration and message handling for integrating with Hasura. The config.dev.toml file now includes a new section for Hasura configuration, specifying the endpoint and secret. In sub.go, the UUID field is set to the UUID of the received message, ensuring proper tracking of parsed messages. This refactor enables seamless integration with Hasura and improves the functionality of the code.
This commit is contained in:
windyboy
2024-07-22 16:23:15 +08:00
parent 3115162454
commit 53f03bbc0a
9 changed files with 131 additions and 9 deletions
+6
View File
@@ -20,6 +20,7 @@ type Config struct {
Nats NatsConfig
Subscription SubscriptionConfig
Timeouts TimeoutsConfig
Hasura HasuraConfig
}
type NatsConfig struct {
@@ -50,6 +51,11 @@ type PatternConfig struct {
Expression *regexp.Regexp
}
type HasuraConfig struct {
Endpoint string
Secret string
}
// LoggerConfig represents the configuration for the logger.
type LoggerConfig struct {
ZapConfig zap.Config `json:"zapConfig"`
+7
View File
@@ -38,6 +38,10 @@ server_timeout = "30s"
reconnect_wait = "10s"
close_timeout = "10s"
ack_wait_timeout = "5s"
[hasura]
endpoint = "http://localhost:8080/v1/graphql"
secret = "aviation-test"
`
tmpFile, err := os.CreateTemp("", "config.*.toml")
Expect(err).NotTo(HaveOccurred())
@@ -68,6 +72,9 @@ ack_wait_timeout = "5s"
Expect(cfg.Nats.Client).To(Equal("test-client"))
Expect(cfg.Nats.URL).To(Equal("nats://localhost:4222"))
Expect(cfg.Subscription.Topic).To(Equal("example-topic"))
Expect(cfg.Subscription.QueueGroup).To(Equal("example-group"))
Expect(cfg.Hasura.Endpoint).To(Equal("http://localhost:8080/v1/graphql"))
Expect(cfg.Hasura.Secret).To(Equal("aviation-test"))
})
})