Skip to content

Commit

Permalink
Deprecate the Streaming option
Browse files Browse the repository at this point in the history
  • Loading branch information
fieldryand committed Feb 18, 2024
1 parent c0f8d17 commit f349164
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
2 changes: 0 additions & 2 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import "github.com/fieldryand/goflow/v2"
func main() {
options := goflow.Options{
UIPath: "ui/",
Streaming: true,
ShowExamples: true,
WithSeconds: true,
}
Expand Down Expand Up @@ -230,7 +229,6 @@ func main() {
You can pass different options to the engine. Options currently supported:
- `Store`: This is [described in more detail below.](#storage)
- `UIPath`: The path to the dashboard code. The default value is an empty string, meaning Goflow serves only the API and not the dashboard. Suggested value if you want the dashboard: `ui/`
- `Streaming`: Whether to stream updates to the dashboard. The default value is `false`, but if you use the dashboard then it's recommended to change this.
- `ShowExamples`: Whether to show the example jobs. Default value: `false`
- `WithSeconds`: Whether to include the seconds field in the cron spec. See the [cron package documentation](https://github.com/robfig/cron) for details. Default value: `false`

Expand Down
1 change: 0 additions & 1 deletion example/goflow-example.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
func main() {
options := goflow.Options{
UIPath: "ui/",
Streaming: true,
ShowExamples: true,
WithSeconds: true,
}
Expand Down
3 changes: 3 additions & 0 deletions goflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ type Goflow struct {
}

// Options to control various Goflow behavior.
//
// Deprecated: Streaming
type Options struct {
Store gokv.Store
UIPath string
Streaming bool
ShowExamples bool
WithSeconds bool
streaming bool
}

// New returns a Goflow engine.
Expand Down
2 changes: 1 addition & 1 deletion routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func (g *Goflow) addStaticRoutes() *Goflow {
}

func (g *Goflow) addStreamRoute() *Goflow {
g.router.GET("/stream", g.stream(g.Options.Streaming))
g.router.GET("/stream", g.stream(g.Options.streaming))
return g
}

Expand Down
7 changes: 4 additions & 3 deletions stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ import (
"github.com/gin-gonic/gin"
)

// Setting clientDisconnect to false makes testing possible.
func (g *Goflow) stream(clientDisconnect bool) func(*gin.Context) {
// Set keepOpen to false when testing--one event will be sent and
// then the channel is closed by the server.
func (g *Goflow) stream(keepOpen bool) func(*gin.Context) {

return func(c *gin.Context) {
job := c.Query("jobname")
Expand Down Expand Up @@ -54,7 +55,7 @@ func (g *Goflow) stream(clientDisconnect bool) func(*gin.Context) {
c.Stream(func(w io.Writer) bool {
if msg, ok := <-chanStream; ok {
c.SSEvent("message", msg)
return clientDisconnect
return keepOpen
}
return false
})
Expand Down

0 comments on commit f349164

Please sign in to comment.