diff --git a/.gitignore b/.gitignore index 3b735ec..51345e9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,21 +1,29 @@ -# If you prefer the allow list template instead of the deny list, see community template: -# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore -# -# Binaries for programs and plugins *.exe +*.BIN *.exe~ *.dll *.so *.dylib - -# Test binary, built with `go test -c` *.test - -# Output of the go coverage tool, specifically when used with LiteIDE *.out - -# Dependency directories (remove the comment below to include it) -# vendor/ - -# Go workspace file +*.app +*.bat +*.cgi +*.com +*.gadget +*.jar +*.pif +*.vb +*.wsf +/out +vendor/ +/Godeps +*.iml +*.ipr +.idea +*.iws +/.vscode +.tmp-* +.env +*.patch go.work diff --git a/cmd/subzero/subzero.go b/cmd/subzero/subzero.go new file mode 100644 index 0000000..26c3cfe --- /dev/null +++ b/cmd/subzero/subzero.go @@ -0,0 +1,37 @@ +package main + +import ( + "context" + "os" + "os/signal" + "syscall" + + "github.com/ice-blockchain/subzero/model" + "github.com/ice-blockchain/subzero/server" +) + +func init() { + server.RegisterWSEventListener(acceptEvent) + server.RegisterWSSubscriptionListener(acceptSubscription) +} + +func main() { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + quit := make(chan os.Signal, 1) + signal.Notify(quit, syscall.SIGINT, syscall.SIGTERM) + + select { + case <-ctx.Done(): + case <-quit: + } +} + +func acceptEvent(event *model.Event) error { + return nil +} + +func acceptSubscription(subscription *model.Subscription) ([]*model.Event, error) { + return nil, nil +} diff --git a/database/command/command.go b/database/command/command.go new file mode 100644 index 0000000..32eaf3d --- /dev/null +++ b/database/command/command.go @@ -0,0 +1,9 @@ +package command + +import "github.com/ice-blockchain/subzero/model" + +var syncQuery func(*model.Event) error + +func RegisterQuerySyncer(sync func(*model.Event) error) { + syncQuery = sync +} diff --git a/database/query/DDL.sql b/database/query/DDL.sql new file mode 100644 index 0000000..e69de29 diff --git a/database/query/query.go b/database/query/query.go new file mode 100644 index 0000000..0e06ad7 --- /dev/null +++ b/database/query/query.go @@ -0,0 +1,14 @@ +package query + +import ( + "github.com/ice-blockchain/subzero/database/command" + "github.com/ice-blockchain/subzero/model" +) + +func init() { + command.RegisterQuerySyncer(acceptEvent) +} + +func acceptEvent(event *model.Event) error { + return nil +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..6dffb88 --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/ice-blockchain/subzero + +go 1.22.0 diff --git a/model/model.go b/model/model.go new file mode 100644 index 0000000..1bd2525 --- /dev/null +++ b/model/model.go @@ -0,0 +1,8 @@ +package model + +type ( + Event struct { + } + Subscription struct { + } +) diff --git a/server/server.go b/server/server.go new file mode 100644 index 0000000..19921b7 --- /dev/null +++ b/server/server.go @@ -0,0 +1,16 @@ +package server + +import ( + "github.com/ice-blockchain/subzero/model" +) + +var wsEventListener func(*model.Event) error +var wsSubscriptionListener func(*model.Subscription) ([]*model.Event, error) + +func RegisterWSEventListener(listen func(*model.Event) error) { + wsEventListener = listen +} + +func RegisterWSSubscriptionListener(listen func(*model.Subscription) ([]*model.Event, error)) { + wsSubscriptionListener = listen +}