Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesread committed Dec 5, 2023
1 parent d7b914f commit 8caba8a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 53 deletions.
12 changes: 6 additions & 6 deletions cmd/japella-adaptor-discord/main.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package main

import (
log "github.com/sirupsen/logrus"
"github.com/jamesread/japella/internal/runtimeconfig"
"github.com/jamesread/japella/internal/amqp"
"github.com/jamesread/japella/internal/adaptor/discord"
"github.com/jamesread/japella/internal/amqp"
"github.com/jamesread/japella/internal/runtimeconfig"
log "github.com/sirupsen/logrus"
"time"

"gopkg.in/yaml.v2"
)

var cfg struct {
Amqp runtimeconfig.AmqpConfig
AppId string
Amqp runtimeconfig.AmqpConfig
AppId string
PublicKey string
Token string
Token string
}

func main() {
Expand Down
12 changes: 6 additions & 6 deletions cmd/japella-bot-utils/main.go
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package main

import (
log "github.com/sirupsen/logrus"
"github.com/jamesread/japella/internal/runtimeconfig"
"github.com/jamesread/japella/internal/amqp"
pb "github.com/jamesread/japella/gen/protobuf"
"github.com/jamesread/japella/internal/amqp"
"github.com/jamesread/japella/internal/runtimeconfig"
log "github.com/sirupsen/logrus"

"gopkg.in/yaml.v2"
)

var cfg struct {
Amqp runtimeconfig.AmqpConfig
AppId string
Amqp runtimeconfig.AmqpConfig
AppId string
PublicKey string
Token string
Token string
}

func main() {
Expand Down
6 changes: 3 additions & 3 deletions internal/adaptor/discord/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ func messageHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}

msg := pb.MessageReceived {
Author: m.Author.ID,
msg := pb.MessageReceived{
Author: m.Author.ID,
Content: m.Content,
Channel: m.ChannelID,
}

amqp.PublishPb(&msg)

//_, _ = s.ChannelMessageSend(m.ChannelID, "pong")
// _, _ = s.ChannelMessageSend(m.ChannelID, "pong")
}
64 changes: 32 additions & 32 deletions internal/amqp/amqp.go
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
package amqp

import (
"github.com/teris-io/shortid"
"fmt"
log "github.com/sirupsen/logrus"
"github.com/streadway/amqp"
"time"
"reflect"
"github.com/teris-io/shortid"
"os"
"reflect"
"sync"
"fmt"
"time"
)

var (
conn *amqp.Connection
channels map[string]*amqp.Channel
conn *amqp.Connection
channels map[string]*amqp.Channel
ConnectionIdentifier string
connMutex sync.Mutex
connMutex sync.Mutex

InstanceId string

Expand Down Expand Up @@ -44,9 +44,9 @@ type HandlerFunc func(d Delivery)

func getDialURL() string {
log.WithFields(log.Fields{
"host": AmqpHost,
"user": AmqpUser,
"port": AmqpPort,
"host": AmqpHost,
"user": AmqpUser,
"port": AmqpPort,
"instance": InstanceId,
}).Infof("AMQP Dial URL")

Expand Down Expand Up @@ -107,11 +107,11 @@ func getConn() (*amqp.Connection, error) {
}

func getMsgType(msg interface{}) string {
if t := reflect.TypeOf(msg); t.Kind() == reflect.Ptr {
return t.Elem().Name()
} else {
return t.Name()
}
if t := reflect.TypeOf(msg); t.Kind() == reflect.Ptr {
return t.Elem().Name()
} else {
return t.Name()
}
}

func Publish(routingKey string, msg amqp.Publishing) error {
Expand Down Expand Up @@ -192,7 +192,7 @@ func Consume(deliveryTag string, handlerFunc HandlerFunc, count int) (*sync.Wait
handlerDoneInfinate.Add(1)

go consumeForever(chanReady, nil, deliveryTag, handlerFunc)

return chanReady, handlerDoneInfinate
} else {
go consumeForever(chanReady, handlerDone, deliveryTag, handlerFunc)
Expand Down Expand Up @@ -221,10 +221,10 @@ func consumeWithChannel(consumerReady *sync.WaitGroup, handlerWait *sync.WaitGro
_, err := c.QueueDeclare(
queueName,
false, // durable
true, // delete when unused
true, // delete when unused
false, // exclusive
true, // nowait
nil, // args
true, // nowait
nil, // args
)

if err != nil {
Expand All @@ -233,28 +233,28 @@ func consumeWithChannel(consumerReady *sync.WaitGroup, handlerWait *sync.WaitGro
}

err = c.QueueBind(
queueName,
queueName,
deliveryTag, // key
"ex_upsilon",
true, // nowait
nil, // args
nil, // args
)

if err != nil {
log.Warnf("Queue bind error: %v %v", deliveryTag, err)
return
return
}

log.Infof("Consumer channel creating for: %v", deliveryTag)

deliveries, err := c.Consume(
queueName, // name
"consume-" + deliveryTag, // consumer tag
false, // noAck
false, // exclusive
false, // noLocal
false, // noWait
nil, // arguments
queueName, // name
"consume-"+deliveryTag, // consumer tag
false, // noAck
false, // exclusive
false, // noLocal
false, // noWait
nil, // arguments
)

if err != nil {
Expand All @@ -272,8 +272,8 @@ func consumeWithChannel(consumerReady *sync.WaitGroup, handlerWait *sync.WaitGro
func newEnvelope(msgType string, body []byte) amqp.Publishing {
return amqp.Publishing{
DeliveryMode: amqp.Persistent,
Timestamp: time.Now(),
ContentType: "application/binary",
Timestamp: time.Now(),
ContentType: "application/binary",
Headers: amqp.Table{
"Upsilon-Msg-Type": msgType,
},
Expand All @@ -283,7 +283,7 @@ func newEnvelope(msgType string, body []byte) amqp.Publishing {

func consumeDeliveries(deliveries <-chan amqp.Delivery, handlerFunc HandlerFunc, handlerWait *sync.WaitGroup) {
for d := range deliveries {
handlerFunc(Delivery {
handlerFunc(Delivery{
Message: d,
})

Expand Down
8 changes: 4 additions & 4 deletions internal/runtimeconfig/amqp.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package runtimeconfig

type AmqpConfig struct {
Host string
User string
Pass string
Port int
Host string
User string
Pass string
Port int
Exchange string
}
4 changes: 2 additions & 2 deletions internal/runtimeconfig/load.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package runtimeconfig

import (
"os"
"io/ioutil"
log "github.com/sirupsen/logrus"
"io/ioutil"
"os"
)

func Load(filename string) []byte {
Expand Down

0 comments on commit 8caba8a

Please sign in to comment.