Remove emitter (#184)

* Remove emitter
This commit is contained in:
Jonas Plum
2022-05-14 01:08:37 +02:00
committed by GitHub
parent 894e607efb
commit dfb501f8b9
31 changed files with 126 additions and 500 deletions

View File

@@ -1,70 +1,69 @@
package bus package bus
import ( import (
"encoding/json" "github.com/arangodb/go-driver"
"log"
emitter "github.com/emitter-io/go/v2" "github.com/SecurityBrewery/catalyst/generated/model"
) )
type ResultMsg struct {
Automation string `json:"automation"`
Data map[string]any `json:"data,omitempty"`
Target *model.Origin `json:"target"`
}
type RequestMsg struct {
IDs []driver.DocumentID `json:"ids"`
Function string `json:"function"`
User string `json:"user"`
}
type JobMsg struct {
ID string `json:"id"`
Automation string `json:"automation"`
Origin *model.Origin `json:"origin"`
Message *model.Message `json:"message"`
}
type DatabaseUpdateType string
const (
DatabaseEntryRead DatabaseUpdateType = "read"
DatabaseEntryCreated DatabaseUpdateType = "created"
DatabaseEntryUpdated DatabaseUpdateType = "updated"
)
type DatabaseUpdateMsg struct {
IDs []driver.DocumentID `json:"ids"`
Type DatabaseUpdateType `json:"type"`
}
type Bus struct { type Bus struct {
config *Config ResultChannel *Channel[*ResultMsg]
client *emitter.Client RequestChannel *Channel[*RequestMsg]
JobChannel *Channel[*JobMsg]
DatabaseChannel *Channel[*DatabaseUpdateMsg]
} }
type Config struct { func New() *Bus {
Host string return &Bus{
Key string ResultChannel: &Channel[*ResultMsg]{},
databaseUpdateBusKey string RequestChannel: &Channel[*RequestMsg]{},
jobBusKey string JobChannel: &Channel[*JobMsg]{},
resultBusKey string DatabaseChannel: &Channel[*DatabaseUpdateMsg]{},
requestKey string }
APIUrl string
} }
func New(c *Config) (*Bus, error) { type Channel[T any] struct {
client, err := emitter.Connect(c.Host, func(_ *emitter.Client, msg emitter.Message) { Subscriber []func(T)
log.Printf("received: '%s' topic: '%s'\n", msg.Payload(), msg.Topic())
})
if err != nil {
return nil, err
}
c.databaseUpdateBusKey, err = client.GenerateKey(c.Key, channelDatabaseUpdate+"/", "rwls", 0)
if err != nil {
return nil, err
}
c.jobBusKey, err = client.GenerateKey(c.Key, channelJob+"/", "rwls", 0)
if err != nil {
return nil, err
}
c.resultBusKey, err = client.GenerateKey(c.Key, channelResult+"/", "rwls", 0)
if err != nil {
return nil, err
}
c.requestKey, err = client.GenerateKey(c.Key, ChannelRequest+"/", "rwls", 0)
if err != nil {
return nil, err
}
return &Bus{config: c, client: client}, err
} }
func (b *Bus) jsonPublish(msg any, channel, key string) error { func (c *Channel[T]) Publish(msg T) {
payload, err := json.Marshal(msg) for _, s := range c.Subscriber {
if err != nil { go s(msg)
return err
} }
return b.client.Publish(key, channel, payload)
} }
func (b *Bus) safeSubscribe(key, channel string, handler func(c *emitter.Client, m emitter.Message)) error { func (c *Channel[T]) Subscribe(handler func(T)) {
defer func() { c.Subscriber = append(c.Subscriber, handler)
if r := recover(); r != nil {
log.Printf("Recovered %s in channel %s\n", r, channel)
}
}()
return b.client.Subscribe(key, channel, handler)
} }

View File

@@ -1,43 +0,0 @@
package bus
import (
"encoding/json"
"log"
"github.com/arangodb/go-driver"
emitter "github.com/emitter-io/go/v2"
)
const channelDatabaseUpdate = "databaseupdate"
type DatabaseUpdateType string
const (
DatabaseEntryRead DatabaseUpdateType = "read"
DatabaseEntryCreated DatabaseUpdateType = "created"
DatabaseEntryUpdated DatabaseUpdateType = "updated"
)
type DatabaseUpdateMsg struct {
IDs []driver.DocumentID `json:"ids"`
Type DatabaseUpdateType `json:"type"`
}
func (b *Bus) PublishDatabaseUpdate(ids []driver.DocumentID, databaseUpdateType DatabaseUpdateType) error {
return b.jsonPublish(&DatabaseUpdateMsg{
IDs: ids,
Type: databaseUpdateType,
}, channelDatabaseUpdate, b.config.databaseUpdateBusKey)
}
func (b *Bus) SubscribeDatabaseUpdate(f func(msg *DatabaseUpdateMsg)) error {
return b.safeSubscribe(b.config.databaseUpdateBusKey, channelDatabaseUpdate, func(c *emitter.Client, m emitter.Message) {
var msg DatabaseUpdateMsg
if err := json.Unmarshal(m.Payload(), &msg); err != nil {
log.Println(err)
return
}
go f(&msg)
})
}

View File

@@ -1,43 +0,0 @@
package bus
import (
"encoding/json"
"log"
emitter "github.com/emitter-io/go/v2"
"github.com/SecurityBrewery/catalyst/generated/model"
)
const channelJob = "job"
type JobMsg struct {
ID string `json:"id"`
Automation string `json:"automation"`
Origin *model.Origin `json:"origin"`
Message *model.Message `json:"message"`
}
func (b *Bus) PublishJob(id, automation string, payload any, context *model.Context, origin *model.Origin) error {
return b.jsonPublish(&JobMsg{
ID: id,
Automation: automation,
Origin: origin,
Message: &model.Message{
Context: context,
Payload: payload,
},
}, channelJob, b.config.jobBusKey)
}
func (b *Bus) SubscribeJob(f func(msg *JobMsg)) error {
return b.safeSubscribe(b.config.jobBusKey, channelJob, func(c *emitter.Client, m emitter.Message) {
var msg JobMsg
if err := json.Unmarshal(m.Payload(), &msg); err != nil {
log.Println(err)
return
}
go f(&msg)
})
}

View File

@@ -1,37 +0,0 @@
package bus
import (
"encoding/json"
"log"
"github.com/arangodb/go-driver"
emitter "github.com/emitter-io/go/v2"
)
const ChannelRequest = "request"
type RequestMsg struct {
IDs []driver.DocumentID `json:"ids"`
Function string `json:"function"`
User string `json:"user"`
}
func (b *Bus) PublishRequest(user, f string, ids []driver.DocumentID) error {
return b.jsonPublish(&RequestMsg{
User: user,
Function: f,
IDs: ids,
}, ChannelRequest, b.config.requestKey)
}
func (b *Bus) SubscribeRequest(f func(msg *RequestMsg)) error {
return b.safeSubscribe(b.config.requestKey, ChannelRequest, func(c *emitter.Client, m emitter.Message) {
msg := &RequestMsg{}
if err := json.Unmarshal(m.Payload(), msg); err != nil {
log.Println(err)
return
}
go f(msg)
})
}

View File

@@ -1,34 +0,0 @@
package bus
import (
"encoding/json"
"log"
emitter "github.com/emitter-io/go/v2"
"github.com/SecurityBrewery/catalyst/generated/model"
)
const channelResult = "result"
type ResultMsg struct {
Automation string `json:"automation"`
Data map[string]any `json:"data,omitempty"`
Target *model.Origin `json:"target"`
}
func (b *Bus) PublishResult(automation string, data map[string]any, target *model.Origin) error {
return b.jsonPublish(&ResultMsg{Automation: automation, Data: data, Target: target}, channelResult, b.config.resultBusKey)
}
func (b *Bus) SubscribeResult(f func(msg *ResultMsg)) error {
return b.safeSubscribe(b.config.resultBusKey, channelResult, func(c *emitter.Client, m emitter.Message) {
msg := &ResultMsg{}
if err := json.Unmarshal(m.Payload(), msg); err != nil {
log.Println(err)
return
}
go f(msg)
})
}

View File

@@ -20,20 +20,12 @@ type busService struct {
network string network string
} }
func New(apiURL, apikey, network string, catalystBus *bus.Bus, db *database.Database) error { func New(apiURL, apikey, network string, catalystBus *bus.Bus, db *database.Database) {
h := &busService{db: db, apiURL: apiURL, apiKey: apikey, network: network, catalystBus: catalystBus} h := &busService{db: db, apiURL: apiURL, apiKey: apikey, network: network, catalystBus: catalystBus}
if err := catalystBus.SubscribeRequest(h.logRequest); err != nil { catalystBus.RequestChannel.Subscribe(h.logRequest)
return err catalystBus.ResultChannel.Subscribe(h.handleResult)
} catalystBus.JobChannel.Subscribe(h.handleJob)
if err := catalystBus.SubscribeResult(h.handleResult); err != nil {
return err
}
if err := catalystBus.SubscribeJob(h.handleJob); err != nil {
return err
}
return nil
} }
func busContext() context.Context { func busContext() context.Context {
@@ -47,7 +39,7 @@ func (h *busService) logRequest(msg *bus.RequestMsg) {
var logEntries []*model.LogEntry var logEntries []*model.LogEntry
for _, i := range msg.IDs { for _, i := range msg.IDs {
logEntries = append(logEntries, &model.LogEntry{ logEntries = append(logEntries, &model.LogEntry{
Type: bus.ChannelRequest, Type: "request",
Reference: i.String(), Reference: i.String(),
Creator: msg.User, Creator: msg.User,
Message: msg.Function, Message: msg.Function,

View File

@@ -82,9 +82,7 @@ func (h *busService) handleJob(automationMsg *bus.JobMsg) {
} }
} }
if err := h.catalystBus.PublishResult(automationMsg.Automation, result, automationMsg.Origin); err != nil { h.catalystBus.ResultChannel.Publish(&bus.ResultMsg{Automation: automationMsg.Automation, Data: result, Target: automationMsg.Origin})
log.Println(err)
}
if err := h.db.JobComplete(ctx, automationMsg.ID, result); err != nil { if err := h.db.JobComplete(ctx, automationMsg.ID, result); err != nil {
log.Println(err) log.Println(err)

View File

@@ -8,7 +8,6 @@ import (
"golang.org/x/oauth2" "golang.org/x/oauth2"
"github.com/SecurityBrewery/catalyst" "github.com/SecurityBrewery/catalyst"
"github.com/SecurityBrewery/catalyst/bus"
"github.com/SecurityBrewery/catalyst/database" "github.com/SecurityBrewery/catalyst/database"
"github.com/SecurityBrewery/catalyst/role" "github.com/SecurityBrewery/catalyst/role"
"github.com/SecurityBrewery/catalyst/storage" "github.com/SecurityBrewery/catalyst/storage"
@@ -41,9 +40,6 @@ type CLI struct {
S3User string `env:"S3_USER" default:"minio" name:"s3-user"` S3User string `env:"S3_USER" default:"minio" name:"s3-user"`
S3Password string `env:"S3_PASSWORD" required:"" name:"s3-password"` S3Password string `env:"S3_PASSWORD" required:"" name:"s3-password"`
EmitterIOHost string `env:"EMITTER_IO_HOST" default:"tcp://emitter:8080"`
EmitterIORKey string `env:"EMITTER_IO_KEY" required:""`
InitialAPIKey string `env:"INITIAL_API_KEY"` InitialAPIKey string `env:"INITIAL_API_KEY"`
} }
@@ -71,6 +67,7 @@ func MapConfig(cli CLI) (*catalyst.Config, error) {
Storage: &storage.Config{Host: cli.S3Host, User: cli.S3User, Password: cli.S3Password}, Storage: &storage.Config{Host: cli.S3Host, User: cli.S3User, Password: cli.S3Password},
Secret: []byte(cli.Secret), Secret: []byte(cli.Secret),
ExternalAddress: cli.ExternalAddress, ExternalAddress: cli.ExternalAddress,
InternalAddress: cli.CatalystAddress,
Auth: &catalyst.AuthConfig{ Auth: &catalyst.AuthConfig{
OIDCIssuer: cli.OIDCIssuer, OIDCIssuer: cli.OIDCIssuer,
OAuth2: &oauth2.Config{ClientID: cli.OIDCClientID, ClientSecret: cli.OIDCClientSecret, RedirectURL: cli.ExternalAddress + "/callback", Scopes: scopes}, OAuth2: &oauth2.Config{ClientID: cli.OIDCClientID, ClientSecret: cli.OIDCClientSecret, RedirectURL: cli.ExternalAddress + "/callback", Scopes: scopes},
@@ -81,7 +78,6 @@ func MapConfig(cli CLI) (*catalyst.Config, error) {
AuthDefaultRoles: roles, AuthDefaultRoles: roles,
AuthAdminUsers: cli.AuthAdminUsers, AuthAdminUsers: cli.AuthAdminUsers,
}, },
Bus: &bus.Config{Host: cli.EmitterIOHost, Key: cli.EmitterIORKey, APIUrl: cli.CatalystAddress + "/api"},
InitialAPIKey: cli.InitialAPIKey, InitialAPIKey: cli.InitialAPIKey,
} }

View File

@@ -55,9 +55,7 @@ func (db *BusDatabase) Query(ctx context.Context, query string, vars map[string]
switch { switch {
case operation.Type == bus.DatabaseEntryCreated, operation.Type == bus.DatabaseEntryUpdated: case operation.Type == bus.DatabaseEntryCreated, operation.Type == bus.DatabaseEntryUpdated:
if err := db.bus.PublishDatabaseUpdate(operation.Ids, operation.Type); err != nil { db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: operation.Ids, Type: operation.Type})
return nil, nil, err
}
} }
return cur, logs, err return cur, logs, err
@@ -92,10 +90,7 @@ func (c *Collection[T]) CreateDocument(ctx, newctx context.Context, key string,
return meta, err return meta, err
} }
err = c.db.bus.PublishDatabaseUpdate([]driver.DocumentID{meta.ID}, bus.DatabaseEntryCreated) c.db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: []driver.DocumentID{meta.ID}, Type: bus.DatabaseEntryCreated})
if err != nil {
return meta, err
}
return meta, nil return meta, nil
} }
@@ -108,10 +103,7 @@ func (c *Collection[T]) CreateEdge(ctx, newctx context.Context, edge *driver.Edg
return meta, err return meta, err
} }
err = c.db.bus.PublishDatabaseUpdate([]driver.DocumentID{meta.ID}, bus.DatabaseEntryCreated) c.db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: []driver.DocumentID{meta.ID}, Type: bus.DatabaseEntryCreated})
if err != nil {
return meta, err
}
return meta, nil return meta, nil
} }
@@ -132,10 +124,7 @@ func (c *Collection[T]) CreateEdges(ctx context.Context, edges []*driver.EdgeDoc
ids = append(ids, meta.ID) ids = append(ids, meta.ID)
} }
err = c.db.bus.PublishDatabaseUpdate(ids, bus.DatabaseEntryCreated) c.db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: ids, Type: bus.DatabaseEntryCreated})
if err != nil {
return metas, err
}
return metas, nil return metas, nil
} }
@@ -162,7 +151,9 @@ func (c *Collection[T]) UpdateDocument(ctx context.Context, key string, update a
return meta, err return meta, err
} }
return meta, c.db.bus.PublishDatabaseUpdate([]driver.DocumentID{meta.ID}, bus.DatabaseEntryUpdated) c.db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: []driver.DocumentID{meta.ID}, Type: bus.DatabaseEntryUpdated})
return meta, nil
} }
func (c *Collection[T]) ReplaceDocument(ctx context.Context, key string, document *T) (meta driver.DocumentMeta, err error) { func (c *Collection[T]) ReplaceDocument(ctx context.Context, key string, document *T) (meta driver.DocumentMeta, err error) {
@@ -173,7 +164,9 @@ func (c *Collection[T]) ReplaceDocument(ctx context.Context, key string, documen
return meta, err return meta, err
} }
return meta, c.db.bus.PublishDatabaseUpdate([]driver.DocumentID{meta.ID}, bus.DatabaseEntryUpdated) c.db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{IDs: []driver.DocumentID{meta.ID}, Type: bus.DatabaseEntryUpdated})
return meta, nil
} }
func (c *Collection[T]) RemoveDocument(ctx context.Context, formatInt string) (meta driver.DocumentMeta, err error) { func (c *Collection[T]) RemoveDocument(ctx context.Context, formatInt string) (meta driver.DocumentMeta, err error) {

View File

@@ -3,7 +3,6 @@ package busdb
import ( import (
"context" "context"
"errors" "errors"
"log"
"strings" "strings"
"github.com/arangodb/go-driver" "github.com/arangodb/go-driver"
@@ -46,12 +45,10 @@ func (db *BusDatabase) LogBatchCreate(ctx context.Context, logentries []*model.L
} }
} }
if ids != nil { if ids != nil {
go func() { go db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{
err := db.bus.PublishDatabaseUpdate(ids, bus.DatabaseEntryCreated) IDs: ids,
if err != nil { Type: bus.DatabaseEntryCreated,
log.Println(err) })
}
}()
} }
_, errs, err := db.logCollection.CreateDocuments(ctx, logentries) _, errs, err := db.logCollection.CreateDocuments(ctx, logentries)

View File

@@ -186,11 +186,17 @@ func publishJobMapping(id, automation string, contextStructs *model.Context, ori
return fmt.Errorf("message generation failed: %w", err) return fmt.Errorf("message generation failed: %w", err)
} }
return publishJob(id, automation, contextStructs, origin, msg, db) db.bus.JobChannel.Publish(&bus.JobMsg{
} ID: id,
Automation: automation,
Origin: origin,
Message: &model.Message{
Context: contextStructs,
Payload: msg,
},
})
func publishJob(id, automation string, contextStructs *model.Context, origin *model.Origin, payload map[string]any, db *Database) error { return nil
return db.bus.PublishJob(id, automation, payload, contextStructs, origin)
} }
func generatePayload(msgMapping map[string]string, contextStructs *model.Context) (map[string]any, error) { func generatePayload(msgMapping map[string]string, contextStructs *model.Context) (map[string]any, error) {

View File

@@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"log"
"sort" "sort"
"strconv" "strconv"
"strings" "strings"
@@ -252,11 +251,10 @@ func (db *Database) TicketBatchCreate(ctx context.Context, ticketForms []*model.
ids = append(ids, driver.NewDocumentID(TicketCollectionName, fmt.Sprint(apiTicket.ID))) ids = append(ids, driver.NewDocumentID(TicketCollectionName, fmt.Sprint(apiTicket.ID)))
} }
go func() { db.bus.DatabaseChannel.Publish(&bus.DatabaseUpdateMsg{
if err := db.bus.PublishDatabaseUpdate(ids, bus.DatabaseEntryUpdated); err != nil { IDs: ids,
log.Println(err) Type: bus.DatabaseEntryCreated,
} })
}()
ticketResponses, err := toTicketResponses(apiTickets) ticketResponses, err := toTicketResponses(apiTickets)
if err != nil { if err != nil {

View File

@@ -13,13 +13,6 @@ services:
ARANGO_ROOT_PASSWORD: foobar ARANGO_ROOT_PASSWORD: foobar
networks: [ catalyst ] networks: [ catalyst ]
emitter:
image: emitter/server
environment:
- EMITTER_LICENSE=PfA8ID8izeSlDUlNZgNXo77DQV9QzlNtxTk64WreCXKfDZsREAVXUXwh20UKOZdkALbLTmOytO_iC6mc_twKAQ:3
# A9RysEsPJni8RaHeg_K0FKXQNfBrUyw-
networks: [ catalyst ]
minio: minio:
image: minio/minio:RELEASE.2021-12-10T23-03-39Z image: minio/minio:RELEASE.2021-12-10T23-03-39Z
environment: environment:

View File

@@ -110,13 +110,3 @@ http {
} }
} }
} }
stream {
server {
listen 9001;
resolver 127.0.0.11 valid=30s;
set $upstream_emitter emitter;
proxy_pass $upstream_emitter:8080;
}
}

11
file.go
View File

@@ -25,7 +25,7 @@ import (
"github.com/SecurityBrewery/catalyst/storage" "github.com/SecurityBrewery/catalyst/storage"
) )
func tusdUpload(db *database.Database, bus *bus.Bus, client *s3.S3, external string) http.HandlerFunc { func tusdUpload(db *database.Database, catalystBus *bus.Bus, client *s3.S3, external string) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
ticketID := chi.URLParam(r, "ticketID") ticketID := chi.URLParam(r, "ticketID")
if ticketID == "" { if ticketID == "" {
@@ -80,10 +80,11 @@ func tusdUpload(db *database.Database, bus *bus.Bus, client *s3.S3, external str
return return
} }
err = bus.PublishRequest(userID, "LinkFiles", []driver.DocumentID{driver.DocumentID(fmt.Sprintf("tickets/%d", doc.ID))}) catalystBus.RequestChannel.Publish(&bus.RequestMsg{
if err != nil { User: userID,
log.Println(err) Function: "LinkFiles",
} IDs: []driver.DocumentID{driver.DocumentID(fmt.Sprintf("tickets/%d", doc.ID))},
})
}() }()
switch r.Method { switch r.Method {

2
go.cap
View File

@@ -75,7 +75,6 @@ github.com/docker/docker/errdefs (network)
github.com/docker/go-connections/nat (network) github.com/docker/go-connections/nat (network)
github.com/docker/go-connections/sockets (file, network, syscall) github.com/docker/go-connections/sockets (file, network, syscall)
github.com/docker/go-connections/tlsconfig (file) github.com/docker/go-connections/tlsconfig (file)
github.com/eclipse/paho.mqtt.golang (file, network, reflect)
github.com/go-chi/chi (network) github.com/go-chi/chi (network)
github.com/go-chi/chi/middleware (file, network) github.com/go-chi/chi/middleware (file, network)
github.com/go-chi/cors (file, network) github.com/go-chi/cors (file, network)
@@ -87,7 +86,6 @@ github.com/golang/protobuf/ptypes/any (reflect)
github.com/golang/protobuf/ptypes/duration (reflect) github.com/golang/protobuf/ptypes/duration (reflect)
github.com/golang/protobuf/ptypes/timestamp (reflect) github.com/golang/protobuf/ptypes/timestamp (reflect)
github.com/google/uuid (file, network) github.com/google/uuid (file, network)
github.com/gorilla/websocket (file, network, unsafe)
github.com/imdario/mergo (reflect) github.com/imdario/mergo (reflect)
github.com/jmespath/go-jmespath (reflect) github.com/jmespath/go-jmespath (reflect)
github.com/sirupsen/logrus (file, reflect) github.com/sirupsen/logrus (file, reflect)

3
go.mod
View File

@@ -11,7 +11,6 @@ require (
github.com/blevesearch/bleve/v2 v2.3.2 github.com/blevesearch/bleve/v2 v2.3.2
github.com/coreos/go-oidc/v3 v3.2.0 github.com/coreos/go-oidc/v3 v3.2.0
github.com/docker/docker v17.12.0-ce-rc1.0.20201201034508-7d75c1d40d88+incompatible github.com/docker/docker v17.12.0-ce-rc1.0.20201201034508-7d75c1d40d88+incompatible
github.com/emitter-io/go/v2 v2.0.9
github.com/go-chi/chi v1.5.4 github.com/go-chi/chi v1.5.4
github.com/go-chi/cors v1.2.1 github.com/go-chi/cors v1.2.1
github.com/gobwas/ws v1.1.0 github.com/gobwas/ws v1.1.0
@@ -56,14 +55,12 @@ require (
github.com/docker/distribution v2.7.1+incompatible // indirect github.com/docker/distribution v2.7.1+incompatible // indirect
github.com/docker/go-connections v0.4.0 // indirect github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0 // indirect github.com/docker/go-units v0.4.0 // indirect
github.com/eclipse/paho.mqtt.golang v1.3.5 // indirect
github.com/gobwas/httphead v0.1.0 // indirect github.com/gobwas/httphead v0.1.0 // indirect
github.com/gobwas/pool v0.2.1 // indirect github.com/gobwas/pool v0.2.1 // indirect
github.com/gogo/protobuf v1.3.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/snappy v0.0.4 // indirect github.com/golang/snappy v0.0.4 // indirect
github.com/gorilla/mux v1.8.0 // indirect github.com/gorilla/mux v1.8.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/kr/pretty v0.3.0 // indirect github.com/kr/pretty v0.3.0 // indirect
github.com/morikuni/aec v1.0.0 // indirect github.com/morikuni/aec v1.0.0 // indirect

7
go.sum
View File

@@ -348,14 +348,9 @@ github.com/docker/spdystream v0.0.0-20160310174837-449fdfce4d96/go.mod h1:Qh8CwZ
github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eclipse/paho.mqtt.golang v1.2.0/go.mod h1:H9keYFcgq3Qr5OUJm/JZI/i6U7joQ8SYLhZwfeOo6Ts=
github.com/eclipse/paho.mqtt.golang v1.3.5 h1:sWtmgNxYM9P2sP+xEItMozsR3w0cqZFlqnNN1bdl41Y=
github.com/eclipse/paho.mqtt.golang v1.3.5/go.mod h1:eTzb4gxwwyWpqBUHGQZ4ABAV7+Jgm1PklsYT/eo8Hcc=
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v0.0.0-20170410110728-ff4f55a20633/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs= github.com/emicklei/go-restful v2.9.5+incompatible/go.mod h1:otzb+WCGbkyDHkqmQmT5YD2WR4BBwUdeQoFo8l/7tVs=
github.com/emitter-io/go/v2 v2.0.9 h1:qA+cnG3kS2uLzo5ETFY6zbHBGl+FmNj0cGf3da7foA4=
github.com/emitter-io/go/v2 v2.0.9/go.mod h1:St++epE1u/6ueCVw47xhu4shpkGNxKRVtkWv4Xi33mg=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
@@ -515,7 +510,6 @@ github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI=
github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So=
github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v0.0.0-20170926233335-4201258b820c/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
@@ -924,7 +918,6 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200425230154-ff2c4b7c35a0/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200505041828-1ed23360d12c/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=

View File

@@ -28,11 +28,11 @@ type Config struct {
IndexPath string IndexPath string
DB *database.Config DB *database.Config
Storage *storage.Config Storage *storage.Config
Bus *bus.Config
Secret []byte Secret []byte
Auth *AuthConfig Auth *AuthConfig
ExternalAddress string ExternalAddress string
InternalAddress string
InitialAPIKey string InitialAPIKey string
Network string Network string
} }
@@ -65,20 +65,14 @@ func New(hooks *hooks.Hooks, config *Config) (*Server, error) {
return nil, err return nil, err
} }
catalystBus, err := bus.New(config.Bus) catalystBus := bus.New()
if err != nil {
return nil, err
}
catalystDatabase, err := database.New(ctx, catalystIndex, catalystBus, hooks, config.DB) catalystDatabase, err := database.New(ctx, catalystIndex, catalystBus, hooks, config.DB)
if err != nil { if err != nil {
return nil, err return nil, err
} }
err = busservice.New(config.Bus.APIUrl, config.InitialAPIKey, config.Network, catalystBus, catalystDatabase) busservice.New(config.InternalAddress+"/api", config.InitialAPIKey, config.Network, catalystBus, catalystDatabase)
if err != nil {
return nil, err
}
catalystService, err := service.New(catalystBus, catalystDatabase, catalystStorage, GetVersion()) catalystService, err := service.New(catalystBus, catalystDatabase, catalystStorage, GetVersion())
if err != nil { if err != nil {

View File

@@ -7,6 +7,7 @@ import (
"github.com/arangodb/go-driver" "github.com/arangodb/go-driver"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/SecurityBrewery/catalyst/bus"
"github.com/SecurityBrewery/catalyst/database" "github.com/SecurityBrewery/catalyst/database"
"github.com/SecurityBrewery/catalyst/generated/model" "github.com/SecurityBrewery/catalyst/generated/model"
) )
@@ -32,7 +33,15 @@ func (s *Service) RunJob(ctx context.Context, form *model.JobForm) (doc *model.J
newJobID := uuid.NewString() newJobID := uuid.NewString()
defer s.publishRequest(ctx, err, "RunJob", jobID(newJobID)) defer s.publishRequest(ctx, err, "RunJob", jobID(newJobID))
err = s.bus.PublishJob(newJobID, form.Automation, form.Payload, msgContext, form.Origin) s.bus.JobChannel.Publish(&bus.JobMsg{
ID: newJobID,
Automation: form.Automation,
Origin: form.Origin,
Message: &model.Message{
Context: msgContext,
Payload: form.Payload,
},
})
return &model.JobResponse{ return &model.JobResponse{
Automation: form.Automation, Automation: form.Automation,
@@ -40,7 +49,7 @@ func (s *Service) RunJob(ctx context.Context, form *model.JobForm) (doc *model.J
Origin: form.Origin, Origin: form.Origin,
Payload: form.Payload, Payload: form.Payload,
Status: "published", Status: "published",
}, err }, nil
} }
func (s *Service) GetJob(ctx context.Context, id string) (*model.JobResponse, error) { func (s *Service) GetJob(ctx context.Context, id string) (*model.JobResponse, error) {

View File

@@ -2,7 +2,6 @@ package service
import ( import (
"context" "context"
"log"
"github.com/arangodb/go-driver" "github.com/arangodb/go-driver"
@@ -34,10 +33,10 @@ func (s *Service) publishRequest(ctx context.Context, err error, function string
userID = user.ID userID = user.ID
} }
go func() { s.bus.RequestChannel.Publish(&bus.RequestMsg{
if err := s.bus.PublishRequest(userID, function, ids); err != nil { User: userID,
log.Println(err) Function: function,
} IDs: ids,
}() })
} }
} }

View File

@@ -9,6 +9,7 @@ import (
"github.com/arangodb/go-driver" "github.com/arangodb/go-driver"
"github.com/google/uuid" "github.com/google/uuid"
"github.com/SecurityBrewery/catalyst/bus"
"github.com/SecurityBrewery/catalyst/database" "github.com/SecurityBrewery/catalyst/database"
"github.com/SecurityBrewery/catalyst/generated/api" "github.com/SecurityBrewery/catalyst/generated/api"
"github.com/SecurityBrewery/catalyst/generated/model" "github.com/SecurityBrewery/catalyst/generated/model"
@@ -135,7 +136,17 @@ func (s *Service) RunArtifact(ctx context.Context, id int64, name string, automa
jobID := uuid.NewString() jobID := uuid.NewString()
origin := &model.Origin{ArtifactOrigin: &model.ArtifactOrigin{TicketId: id, Artifact: name}} origin := &model.Origin{ArtifactOrigin: &model.ArtifactOrigin{TicketId: id, Artifact: name}}
return s.bus.PublishJob(jobID, automation, map[string]string{"default": name}, &model.Context{Artifact: artifact}, origin) s.bus.JobChannel.Publish(&bus.JobMsg{
ID: jobID,
Automation: automation,
Origin: origin,
Message: &model.Message{
Context: &model.Context{Artifact: artifact},
Payload: map[string]string{"default": name},
},
})
return nil
} }
func (s *Service) AddComment(ctx context.Context, i int64, form *model.CommentForm) (doc *model.TicketWithTickets, err error) { func (s *Service) AddComment(ctx context.Context, i int64, form *model.CommentForm) (doc *model.TicketWithTickets, err error) {

View File

@@ -7,8 +7,6 @@ export ARANGO_DB_HOST=http://localhost:8529
export ARANGO_DB_PASSWORD=foobar export ARANGO_DB_PASSWORD=foobar
export S3_HOST=http://localhost:9000 export S3_HOST=http://localhost:9000
export S3_PASSWORD=minio123 export S3_PASSWORD=minio123
export EMITTER_IO_HOST=tcp://localhost:9001
export EMITTER_IO_KEY=A9RysEsPJni8RaHeg_K0FKXQNfBrUyw-
export AUTH_BLOCK_NEW=false export AUTH_BLOCK_NEW=false
export AUTH_DEFAULT_ROLES=analyst,admin export AUTH_DEFAULT_ROLES=analyst,admin

View File

@@ -45,11 +45,6 @@ func Config(ctx context.Context) (*catalyst.Config, error) {
User: "minio", User: "minio",
Password: "minio123", Password: "minio123",
}, },
Bus: &bus.Config{
Host: "tcp://localhost:9001",
Key: "A9RysEsPJni8RaHeg_K0FKXQNfBrUyw-",
APIUrl: "http://localhost:8002/api",
},
Secret: []byte("4ef5b29539b70233dd40c02a1799d25079595565e05a193b09da2c3e60ada1cd"), Secret: []byte("4ef5b29539b70233dd40c02a1799d25079595565e05a193b09da2c3e60ada1cd"),
Auth: &catalyst.AuthConfig{ Auth: &catalyst.AuthConfig{
OIDCIssuer: "http://localhost:9002/auth/realms/catalyst", OIDCIssuer: "http://localhost:9002/auth/realms/catalyst",
@@ -100,10 +95,7 @@ func Bus(t *testing.T) (context.Context, *catalyst.Config, *bus.Bus, error) {
t.Fatal(err) t.Fatal(err)
} }
catalystBus, err := bus.New(config.Bus) catalystBus := bus.New()
if err != nil {
t.Fatal(err)
}
return ctx, config, catalystBus, err return ctx, config, catalystBus, err
} }

View File

@@ -1,34 +0,0 @@
<template>
<svg
width="64"
viewBox="74.499 105.376 55.861 54.285"
height="64"
>
<path
style="fill: #ffffff"
id="path1566"
fill="#577138"
d="m128.867 130.714c-1.045-3.482-3.378-6.163-5.467-9.02-3.97-5.362-9.123-8.322-13.86-8.357-9.088-.174-15.495 3.97-18.246 10.48-.348.836-.8 1.184-1.637 1.358-3.03.696-6.06 1.393-8.88 2.82-1.915.975-3.865 1.88-5.084 3.76-1.532 2.368-1.358 4.875-.766 7.487 1.532 6.476 5.467 10.48 11.978 11.943 4.005.87 7.904.766 11.56-1.323 2.298-1.288 4.144-3.133 5.955-5.015.453-.487.8-.592 1.393-.313l3.343 1.637c3.552 1.776 7.173 3.238 11.247 2.994 6.477-.383 10.342-4.736 9.924-11.073-.14-2.507-.73-4.944-1.463-7.382zm-23.992 8.8c-3.9 2.6-7.94 4.875-12.605 5.815-1.497.314-2.995.418-4.005.348-3.76 0-6.93-.382-9.715-2.298-3.273-2.3-4.666-7.313-2.786-10.83.592-1.15 1.602-1.985 2.716-2.647 3.865-2.403 8.183-3.517 12.57-4.422 4.56-.975 9.192-2.02 13.963-1.985 2.298 0 4.352.905 5.815 2.75 1.288 1.67.906 3.552.28 5.328-1.22 3.343-3.308 6-6.233 7.94zm23.713 2.856c-1.463 3.656-4.562 4.875-8.078 5.397-3.76.557-6.86-1.22-10.063-2.716-1.045-.487-2.055-1.114-3.134-1.532-.94-.348-1.08-.697-.313-1.358 1.184-1.497 2.368-2.995 3.308-4.667 1.15-2.472 1.846-5.084 1.846-7.834 0-4.248-2.264-6.13-6.546-6.616-.836-.104-1.706-.035-2.577-.035-2.9.2-5.78.662-8.636 1.184-.592-.035-1.323.662-1.706.035-.278-.453.418-1 .73-1.497 2.1-3.62 5.223-5.85 9.158-7.104 3.447-1.08 6.86-1.323 10.4-.383 2.925.766 5.014 2.542 6.93 4.666 2.368 2.6 4.527 5.328 6.268 8.357 1.706 2.96 2.577 6.128 2.82 9.506.07 1.566.2 3.1-.418 4.597z"
/>
<path
style="fill: #ffffff"
id="path1570"
fill="#a2b24f"
d="m126.185 128.277c-1.776-3.03-3.935-5.78-6.268-8.357-1.915-2.124-4.005-3.9-6.93-4.666-3.55-.94-6.964-.697-10.4.383-3.935 1.22-7.07 3.482-9.158 7.104-.278.487-1 1.045-.73 1.497.383.592 1.114-.07 1.706-.035.696-2.263 2.228-3.935 4.144-5.153 3.378-2.194 7.138-3.1 11.178-3.03 3.9.104 6.964 1.8 9.54 4.63 1.88 2.054 3.517 4.353 5.12 6.616 2.542 3.587 3.935 7.556 3.656 12.013-.2 3.17-1.67 5.537-4.77 6.686-2.542.94-5.12 1.15-7.695.035-1.497-.627-3.065-1.08-4.527-1.8-1.358-.66-2.925-.836-4.04-1.95-.8.66-.627 1 .313 1.358 1.08.417 2.1 1.045 3.134 1.532 3.204 1.497 6.337 3.273 10.063 2.716 3.517-.522 6.616-1.775 8.078-5.397.592-1.497.488-3.03.383-4.56-.2-3.482-1.08-6.65-2.786-9.6zm-15.112 3.308c.627-1.776 1-3.656-.28-5.328-1.462-1.88-3.482-2.75-5.815-2.75-4.736-.035-9.367 1-13.998 1.985-4.387.94-8.705 2.02-12.57 4.422-1.114.697-2.124 1.532-2.716 2.647-1.845 3.517-.487 8.53 2.786 10.83 2.786 1.95 5.954 2.298 9.715 2.298 1 .07 2.542-.07 4.004-.348 4.666-.94 8.705-3.204 12.605-5.815 2.994-1.95 5.084-4.596 6.268-7.94zm-8.044 8.183c-3.308 1.985-6.65 3.9-10.516 4.596-3.134.557-6.338.732-9.47-.07-3.656-.87-6.477-4.18-6.616-7.94-.07-2.055.94-3.726 2.507-5.05 2.438-2.054 5.328-3.134 8.392-3.796.07 0 .174.104.278.174 2.577-1.985 5.502-2.368 8.636-2.124.278-.66.94-.453 1.428-.592 2.68-.662 5.397-.94 8.078-.383 5.05 1 5.676 3.83 4.04 7.94-1.288 3.308-3.83 5.467-6.755 7.243zm8.6-2.508c3.308.2 5.64-2.9 5.64-5.57 0-3.726-1.985-6.407-4.84-8.53-1.358-.975-2.9-1.636-4.562-1.045-1.428.487-2.82.8-4.318.697-.174 0-.348.14-.522.174.87 0 1.706-.07 2.577.034 4.283.488 6.546 2.368 6.546 6.616 0 2.75-.696 5.362-1.846 7.835.383-.245.836-.245 1.323-.2z"
/>
<path
style="fill: #ffffff"
id="path1574"
fill="#5e3108"
d="m83.564 134.823c-.105.905.14 1.636 1 2.16 3.134 1.915 6.477 3.03 10.203 2.6 2.75-.313 5.327-1.184 7.452-3.03 1.985-1.706 2.368-3.83 1.044-6.024-1.637-2.68-3.97-4.353-7.034-4.944-3.1-.244-6.06.14-8.636 2.124-2.228 1.88-3.726 4.18-4.04 7.104z"
/>
</svg>
</template>
<script>
export default {
name: "ArangoIcon",
};
</script>
<style scoped></style>

View File

@@ -1,31 +0,0 @@
<template>
<svg viewBox="0 0 205.18876 205.19" height="205.19" width="205.18875" id="svg4136">
<g transform="matrix(1.25,0,0,-1.25,0,205.19)" id="g4144">
<g transform="scale(0.1)" style="fill: #ff0000" clip-path="url(#clipPath4152)" id="g4150">
<path
id="path4156"
style="fill: #ffffff; fill-opacity: 1; fill-rule: nonzero; stroke: none"
d="m 820.992,276.18 c -295.238,0 -535.441,240.211 -535.441,535.465 0,295.245 240.203,535.445 535.441,535.445 295.258,0 535.468,-240.2 535.468,-535.445 0,-58.926 -47.77,-106.696 -106.71,-106.696 -58.92,0 -106.69,47.77 -106.69,106.696 0,177.574 -144.482,322.055 -322.068,322.055 -177.574,0 -322.047,-144.481 -322.047,-322.055 0,-177.575 144.473,-322.075 322.047,-322.075 58.93,0 106.703,-47.769 106.703,-106.691 0,-58.93 -47.773,-106.699 -106.703,-106.699"
/>
<path
id="path4158"
style="fill: #ffffff; fill-opacity: 1; fill-rule: nonzero; stroke: none"
d="m 1009.77,811.645 c 0,-104.254 -84.516,-188.774 -188.778,-188.774 -104.258,0 -188.769,84.52 -188.769,188.774 0,104.257 84.511,188.775 188.769,188.775 104.262,0 188.778,-84.518 188.778,-188.775"
/>
<path
id="path4160"
style="fill: #ffffff; fill-opacity: 1; fill-rule: nonzero; stroke: none"
d="m 820.758,0 c -45.328,0 -82.074,36.7617 -82.074,82.0781 0,45.3319 36.746,82.0629 82.074,82.0629 362.052,0 656.592,294.57 656.592,656.625 0,362.054 -294.54,656.604 -656.592,656.604 -362.059,0 -656.602,-294.55 -656.602,-656.604 0,-45.325 -36.758,-82.075 -82.0857,-82.075 C 36.7461,738.691 0,775.441 0,820.766 c 0,452.564 368.18,820.754 820.758,820.754 452.562,0 820.752,-368.19 820.752,-820.754 C 1641.51,368.191 1273.32,0 820.758,0"
/>
</g>
</g>
</svg>
</template>
<script>
export default {
name: "EmitterIcon",
};
</script>
<style scoped></style>

View File

@@ -1,22 +0,0 @@
<template>
<svg
viewBox="-0.231 -10.008 1143.859 1147.992"
width="2500"
height="2500"
>
<path
style="fill: #ffffff"
id="path887"
fill="#f8e6ea"
d="m 649.50958,1130.9299 c -1.375,-0.74 -16.788,-15.67 -34.25,-33.18 l -31.75,-31.834 V 858.86783 c 0,-113.876 -0.289,-207.336 -0.641,-207.69 -0.649,-0.647 -52.692,25.508 -205.773,103.415 -46.152,23.488 -84.548,42.462 -85.324,42.164 -0.906,-0.347 -1.206,-1.359 -0.837,-2.827 0.315,-1.257 1.018,-6.483 1.562,-11.614 2.754,-25.985 23.256,-87.028 45.006,-134 59.272,-128.003 155.174,-234.087 277.19,-306.617 19.913,-11.837 36.64,-20.494 38.337,-19.843 1.294,0.497 1.48,13.97 1.48,107.1 0,76.287 0.31,106.531 1.091,106.531 0.6,0 5.174,-2.109 10.165,-4.686 35.003,-18.079 60.409,-51.848 68.9,-91.58 2.871,-13.436 3.13,-37.923 0.537,-50.916 -4.763,-23.874 -15.756,-46.334 -31.252,-63.852 -7.652,-8.65 -33.057,-35.365 -77.946,-81.966 -67.875,-70.462 -80.303,-83.931 -88.255,-95.65 -5.834,-8.6 -10.87,-19.113 -13.922,-29.062 -2.447,-7.979 -2.7,-10.307 -2.754,-25.288003 -0.065,-18.287 0.974,-23.978 6.985,-38.248 11.6,-27.537 41.822,-53.2229997 66.951,-56.9029997 17.627,-2.58 39.898,-2.083 54.386,1.217 11.81,2.69 30.942,14.2249997 44.057,26.5619997 15.396,14.484 23.147,26.045 81.04,120.872003 68.315,111.898 76.461,125.692 77.628,131.443 1.155,5.692 0.319,8.097 -2.79,8.027 -2.589,-0.058 -1.805,0.745 -124.8,-127.97 -10.774,-11.275 -29.537,-31.075 -41.694,-44 -31.729,-33.731003 -44.894,-46.440003 -50.863,-49.098003 -7.641,-3.404 -18.242,-3.248 -25.625,0.378 -14.476,7.109 -21.328,23.505 -15.867,37.970003 2.708,7.171 -1.064,3.061 87.873,95.75 39.844,41.525 75.834,79.55 79.979,84.5 66.885,79.884 61.447,198.583 -12.46,271.993 -16.97,16.855 -33.934,28.403 -65.364,44.493 -10.725,5.49 -20.962,10.883 -22.75,11.984 l -3.25,2 v 257.934 c 0,141.86307 -0.273,258.64407 -0.607,259.51407 -0.703,1.833 -1.03,1.835 -4.393,0.024 z m -177.63,-500.38507 c 87.548,-44.936 105.617,-54.442 108.183,-56.912 1.61,-1.548 2.312,-3.78 2.792,-8.857 0.969,-10.263 0.782,-118.091 -0.206,-118.702 -2.176,-1.345 -38.95,31.338 -63.639,56.56 -42.682,43.6 -78.365,92.834 -107.7,148.595 -3.836,7.292 -6.656,13.259 -6.267,13.259 0.389,0 30.467,-15.274 66.838,-33.943 z"
/>
</svg>
</template>
<script>
export default {
name: "MinioIcon",
};
</script>
<style scoped></style>

View File

@@ -1,43 +0,0 @@
<template>
<svg
viewBox="0 0 512 512"
width="512"
height="512"
>
<g id="g861" transform="translate(0 -540.36)">
<g style="fill: #ffffff" id="g841" transform="matrix(6.1195921,0,0,6.1195921,-464.85522,-1122.4443)">
<path
id="path839"
fill="#ffffff"
d="m 120.6731,296.55103 c -2.3846,0 -4.3789,2.0376 -4.3789,4.4222 v 0.77344 c -2.2304,0.10995 -4.0388,0.5467 -5.3281,1.4316 -1.5951,1.0948 -2.4675,2.582 -3.1816,3.877 -0.71415,1.295 -1.2996,2.4093 -2.1504,3.1894 -0.72545,0.66525 -1.7997,1.1216 -3.4512,1.3301 -0.21359,-2.192 -2.0615,-3.9512 -4.305197,-3.9512 h -17.167 c -2.3846,0 -4.4165,1.965 -4.4165,4.3496 v 4.2422 c 0,2.3846 2.0319,4.3516 4.4165,4.3516 h 17.167 c 2.384597,0 4.387197,-1.9669 4.387197,-4.3516 v -1.6133 c 9.7257,0.15307 12.467,2.6032 15.594,5.3379 3.0006,2.6241 6.6658,5.3789 15.436,5.4948 v 0.73633 c 0,2.3846 2.0695,4.3799 4.4541,4.3799 h 17.092 c 2.3846,0 4.4541,-1.9952 4.4541,-4.3799 v -4.2422 c 0,-2.3846 -2.0695,-4.3779 -4.4541,-4.3779 h -17.092 c -2.3846,0 -4.4541,1.9933 -4.4541,4.3779 v 0.58594 c -8.0984,-0.0599 -10.486,-2.1557 -13.498,-4.7897 -2.5035,-2.1893 -5.6398,-4.5852 -11.947,-5.5859 1.176,-1.1795 1.8834,-2.5192 2.5137,-3.6621 0.67724,-1.228 1.2899,-2.2006 2.2695,-2.873 0.76303,-0.52371 1.9757,-0.83922 3.6621,-0.93945 v 0.55078 c 0,2.3846 1.9943,4.3356 4.3789,4.3356 h 17.242 c 2.3846,0 4.3789,-1.951 4.3789,-4.3356 v -4.2422 c 0,-2.3846 -1.9943,-4.4222 -4.3789,-4.4222 z m 0,3 h 17.242 c 0.80513,0 1.3789,0.6171 1.3789,1.4222 v 4.2422 c 0,0.80514 -0.57378,1.3356 -1.3789,1.3356 h -17.242 c -0.80513,0 -1.3789,-0.53045 -1.3789,-1.3356 v -4.2422 c 0,-0.80513 0.57378,-1.4222 1.3789,-1.4222 z m -39.961997,11.016 h 17.167 c 0.80513,0 1.4165,0.60112 1.4165,1.4062 v 4.2422 c 0,0.80513 -0.61138,1.4082 -1.4165,1.4082 h -17.167 c -0.80513,0 -1.4165,-0.60307 -1.4165,-1.4082 v -4.2422 c 0,-0.80513 0.61137,-1.4062 1.4165,-1.4062 z m 57.037997,9.984 h 17.092 c 0.80513,0 1.4541,0.5728 1.4541,1.3779 v 4.168 c 0,0.80513 -0.64898,1.4541 -1.4541,1.4541 h -17.092 c -0.80513,0 -1.4541,-0.64897 -1.4541,-1.4541 v -4.168 c 0,-0.80513 0.64897,-1.3779 1.4541,-1.3779 z"
style="
color: #000000;
text-indent: 0;
text-decoration: none;
text-decoration-line: none;
text-decoration-style: solid;
text-decoration-color: #000000;
text-transform: none;
white-space: normal;
isolation: auto;
mix-blend-mode: normal;
solid-color: #000000;
fill: #ffffff;
color-rendering: auto;
image-rendering: auto;
shape-rendering: auto;
"
/>
</g>
<g id="g859" fill="#8f0000" transform="matrix(1.0024 0 0 1.0024 .26914 -2.6855)" />
</g>
</svg>
</template>
<script>
export default {
name: "NodeRedIcon",
};
</script>
<style scoped></style>

View File

@@ -1,10 +1,6 @@
import "@mdi/font/css/materialdesignicons.css"; import "@mdi/font/css/materialdesignicons.css";
import Vue from "vue"; import Vue from "vue";
import Vuetify from "vuetify/lib"; import Vuetify from "vuetify/lib";
import MinioIcon from "../components/icons/MinioIcon.vue";
import NodeRedIcon from "../components/icons/NodeRedIcon.vue";
import ArangoIcon from "../components/icons/ArangoIcon.vue";
import EmitterIcon from "../components/icons/EmitterIcon.vue";
Vue.use(Vuetify); Vue.use(Vuetify);
@@ -73,18 +69,6 @@ export default new Vuetify({
}, },
icons: { icons: {
values: { values: {
minio: {
component: MinioIcon,
},
nodered: {
component: NodeRedIcon,
},
arango: {
component: ArangoIcon,
},
emitter: {
component: EmitterIcon,
},
}, },
}, },
}); });

View File

@@ -1,21 +0,0 @@
<template>
<object data="http://localhost:9001/keygen">
<embed src="http://localhost:9001/keygen" />
Error: Embedded data could not be displayed.
</object>
</template>
<script>
export default {
name: "Emitter",
};
</script>
<style scoped>
object,
embed {
padding-left: 56px;
height: 100%;
width: 100%;
}
</style>

View File

@@ -3,7 +3,6 @@ package catalyst
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"log"
"net/http" "net/http"
"sync" "sync"
@@ -49,7 +48,7 @@ func handleWebSocket(catalystBus *bus.Bus) http.HandlerFunc {
broker := websocketBroker{clients: map[string]chan []byte{}} broker := websocketBroker{clients: map[string]chan []byte{}}
// send all messages from bus to websocket // send all messages from bus to websocket
err := catalystBus.SubscribeDatabaseUpdate(func(msg *bus.DatabaseUpdateMsg) { catalystBus.DatabaseChannel.Subscribe(func(msg *bus.DatabaseUpdateMsg) {
b, err := json.Marshal(map[string]any{ b, err := json.Marshal(map[string]any{
"action": "update", "action": "update",
"ids": msg.IDs, "ids": msg.IDs,
@@ -60,9 +59,6 @@ func handleWebSocket(catalystBus *bus.Bus) http.HandlerFunc {
broker.Publish(b) broker.Publish(b)
}) })
if err != nil {
log.Println(err)
}
return func(w http.ResponseWriter, r *http.Request) { return func(w http.ResponseWriter, r *http.Request) {
conn, _, _, err := ws.UpgradeHTTP(r, w) conn, _, _, err := ws.UpgradeHTTP(r, w)