-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from quix-labs/dev
Restructuration (BREAKING CHANGES)
- Loading branch information
Showing
36 changed files
with
805 additions
and
467 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,4 +24,7 @@ Thumbs.db | |
/go/src/ | ||
go.sum | ||
*.prof | ||
/development | ||
/development | ||
go.work | ||
go.work.sum | ||
coverage.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.PHONY: test test-coverage | ||
|
||
test: | ||
go test ./... | ||
|
||
test-coverage: | ||
go test -coverprofile=coverage.out ./... | ||
go tool cover -html=coverage.out -o coverage.html | ||
xdg-open coverage.html |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/quix-labs/flash" | ||
"github.com/quix-labs/flash/drivers/trigger" | ||
) | ||
|
||
func main() { | ||
postsListener, _ := flash.NewListener(&flash.ListenerConfig{ | ||
Table: "public.posts", | ||
MaxParallelProcess: 50, // Default to 1, you can use -1 for infinite goroutine | ||
}) | ||
|
||
stop, err := postsListener.On(flash.OperationInsert|flash.OperationDelete, func(event flash.Event) { | ||
switch typedEvent := event.(type) { | ||
case *flash.InsertEvent: | ||
fmt.Printf("insert - new: %+v\n", typedEvent.New) | ||
case *flash.DeleteEvent: | ||
fmt.Printf("delete - old: %+v \n", typedEvent.Old) | ||
} | ||
}) | ||
if err != nil { | ||
fmt.Println(err) | ||
} | ||
defer stop() | ||
|
||
flashClient, _ := flash.NewClient(&flash.ClientConfig{ | ||
DatabaseCnx: "postgresql://devuser:devpass@localhost:5432/devdb", | ||
Driver: trigger.NewDriver(&trigger.DriverConfig{}), | ||
}) | ||
flashClient.Attach(postsListener) | ||
go flashClient.Start() // Error Handling | ||
defer flashClient.Close() | ||
|
||
select {} // Keep process running | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.