Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: block/ftl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 2439e6e587a1eebd9fee959f4802dde4bcbff9bd
Choose a base ref
..
head repository: block/ftl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: a186041fcbd52898f301ecbe4d87ade8056e4a6e
Choose a head ref
Showing with 1,105 additions and 1 deletion.
  1. +1 −0 backend/admin/testdata/go/dischema/go.sum
  2. +1 −0 backend/console/testdata/go/console/go.sum
  3. +1 −0 backend/controller/leases/testdata/go/leases/go.sum
  4. +1 −0 backend/controller/sql/testdata/go/database/go.sum
  5. +1 −0 backend/controller/sql/testdata/go/mysql/go.sum
  6. +1 −0 backend/ingress/testdata/go/httpingress/go.sum
  7. +1 −0 backend/provisioner/testdata/go/echo/go.sum
  8. +1 −0 backend/runner/pubsub/testdata/go/publisher/go.sum
  9. +1 −0 backend/runner/pubsub/testdata/go/subscriber/go.sum
  10. +1 −0 backend/timeline/testdata/go/cron/go.sum
  11. +1 −0 backend/timeline/testdata/go/echo/go.sum
  12. +1 −0 backend/timeline/testdata/go/ingress/go.sum
  13. +1 −0 backend/timeline/testdata/go/publisher/go.sum
  14. +1 −0 backend/timeline/testdata/go/subscriber/go.sum
  15. +1 −0 backend/timeline/testdata/go/time/go.sum
  16. 0 bin/{.mk-0.10.0.pkg → .mk-0.10.1.pkg}
  17. +1 −1 bin/mk
  18. +131 −0 cmd/raft-tester/main.go
  19. +1 −0 common/internal/tests/testdata/go/omitempty/go.sum
  20. +1 −0 common/internal/tests/testdata/go/runtimereflection/go.sum
  21. +1 −0 examples/go/cron/go.sum
  22. +1 −0 examples/go/echo/go.sum
  23. +1 −0 examples/go/http/go.sum
  24. +1 −0 examples/go/mysql/go.sum
  25. +1 −0 examples/go/postgres/go.sum
  26. +1 −0 examples/go/pubsub/go.sum
  27. +1 −0 examples/go/time/go.sum
  28. +1 −0 frontend/cli/testdata/go/echo/go.sum
  29. +1 −0 frontend/cli/testdata/go/time/go.sum
  30. +1 −0 go-runtime/compile/testdata/go/echo/go.sum
  31. +1 −0 go-runtime/compile/testdata/go/external/go.sum
  32. +1 −0 go-runtime/compile/testdata/go/notexportedverb/go.sum
  33. +1 −0 go-runtime/compile/testdata/go/one/go.sum
  34. +1 −0 go-runtime/compile/testdata/go/time/go.sum
  35. +1 −0 go-runtime/compile/testdata/go/two/go.sum
  36. +1 −0 go-runtime/compile/testdata/go/undefinedverb/go.sum
  37. +1 −0 go-runtime/ftl/ftltest/testdata/go/outer/go.sum
  38. +1 −0 go-runtime/ftl/ftltest/testdata/go/pubsub/go.sum
  39. +1 −0 go-runtime/ftl/ftltest/testdata/go/subscriber/go.sum
  40. +1 −0 go-runtime/ftl/ftltest/testdata/go/time/go.sum
  41. +1 −0 go-runtime/ftl/ftltest/testdata/go/verbtypes/go.sum
  42. +1 −0 go-runtime/ftl/ftltest/testdata/go/wrapped/go.sum
  43. +1 −0 go-runtime/ftl/testdata/go/echo/go.sum
  44. +1 −0 go-runtime/ftl/testdata/go/mapper/go.sum
  45. +1 −0 go-runtime/ftl/testdata/go/time/go.sum
  46. +1 −0 go-runtime/ftl/testdata/go/typeregistry/go.sum
  47. +1 −0 go-runtime/goplugin/testdata/alpha/go.sum
  48. +1 −0 go-runtime/goplugin/testdata/another/go.sum
  49. +1 −0 go-runtime/goplugin/testdata/other/go.sum
  50. +1 −0 go-runtime/internal/testdata/go/mapper/go.sum
  51. +1 −0 go-runtime/schema/testdata/failing/go.sum
  52. +1 −0 go-runtime/schema/testdata/named/go.sum
  53. +1 −0 go-runtime/schema/testdata/one/go.sum
  54. +1 −0 go-runtime/schema/testdata/parent/go.sum
  55. +1 −0 go-runtime/schema/testdata/pubsub/go.sum
  56. +1 −0 go-runtime/schema/testdata/subscriber/go.sum
  57. +1 −0 go-runtime/schema/testdata/two/go.sum
  58. +1 −0 go-runtime/schema/testdata/validation/go.sum
  59. +26 −0 go.mod
  60. +403 −0 go.sum
  61. +1 −0 internal/buildengine/languageplugin/testdata/go/plugintest/go.sum
  62. +1 −0 internal/buildengine/testdata/alpha/go.sum
  63. +1 −0 internal/buildengine/testdata/another/go.sum
  64. +1 −0 internal/buildengine/testdata/other/go.sum
  65. +1 −0 internal/projectconfig/testdata/go/echo/go.sum
  66. +1 −0 internal/projectconfig/testdata/go/findconfig/go.sum
  67. +1 −0 internal/projectconfig/testdata/go/validateconfig/go.sum
  68. +223 −0 internal/raft/cluster.go
  69. +143 −0 internal/raft/cluster_test.go
  70. +109 −0 internal/raft/statemachine.go
  71. +1 −0 internal/watch/testdata/alpha/go.sum
  72. +1 −0 internal/watch/testdata/another/go.sum
  73. +1 −0 internal/watch/testdata/other/go.sum
  74. +1 −0 jvm-runtime/testdata/go/gomodule/go.sum
  75. +1 −0 smoketest/echo/go.sum
  76. +1 −0 smoketest/origin/go.sum
  77. +1 −0 smoketest/relay/go.sum
1 change: 1 addition & 0 deletions backend/admin/testdata/go/dischema/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/console/testdata/go/console/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/controller/leases/testdata/go/leases/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/controller/sql/testdata/go/database/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/controller/sql/testdata/go/mysql/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/ingress/testdata/go/httpingress/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/provisioner/testdata/go/echo/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/runner/pubsub/testdata/go/publisher/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/runner/pubsub/testdata/go/subscriber/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/cron/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/echo/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/ingress/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/publisher/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/subscriber/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions backend/timeline/testdata/go/time/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
2 changes: 1 addition & 1 deletion bin/mk
131 changes: 131 additions & 0 deletions cmd/raft-tester/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package main

import (
"context"
"encoding/binary"
"errors"
"fmt"
"io"
"log"
"os"
"os/signal"
"time"

"github.com/alecthomas/kong"
"github.com/lni/dragonboat/v4"
"golang.org/x/exp/rand"
"golang.org/x/sync/errgroup"

"github.com/block/ftl/internal/raft"
)

var cli struct {
RaftConfig raft.RaftConfig `embed:"" prefix:"raft-"`
}

type IntStateMachine struct {
sum int64
}

type IntEvent int64

func (i *IntEvent) UnmarshalBinary(data []byte) error { //nolint:unparam
*i = IntEvent(binary.BigEndian.Uint64(data))
return nil
}

func (i IntEvent) MarshalBinary() ([]byte, error) { //nolint:unparam
return binary.BigEndian.AppendUint64([]byte{}, uint64(i)), nil
}

var _ raft.StateMachine[int64, int64, IntEvent, *IntEvent] = &IntStateMachine{}

func (s IntStateMachine) Lookup(key int64) (int64, error) {
return s.sum, nil
}

func (s *IntStateMachine) Update(msg IntEvent) error {
s.sum += int64(msg)
return nil
}

func (s IntStateMachine) Close() error {
return nil
}

func (s IntStateMachine) Recover(reader io.Reader) error {
err := binary.Read(reader, binary.BigEndian, &s.sum)
if err != nil {
return fmt.Errorf("failed to recover from snapshot: %w", err)
}
return nil
}

func (s IntStateMachine) Save(writer io.Writer) error {
err := binary.Write(writer, binary.BigEndian, s.sum)
if err != nil {
return fmt.Errorf("failed to save snapshot: %w", err)
}
return nil
}

func main() {
kctx := kong.Parse(&cli)
ctx, _ := signal.NotifyContext(context.Background(), os.Interrupt)

cluster := raft.New(&cli.RaftConfig)
shard := raft.AddShard(ctx, cluster, 1, &IntStateMachine{})

wg, ctx := errgroup.WithContext(ctx)
messages := make(chan int)

wg.Go(func() error {
defer close(messages)
// send a random number every 10 seconds
ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop()
for {
select {
case <-ticker.C:
messages <- rand.Intn(1000)
case <-ctx.Done():
return nil
}
}
})
wg.Go(func() error {
return cluster.Start(ctx)
})
wg.Go(func() error {
ticker := time.NewTicker(10 * time.Second)
for {
select {
case msg := <-messages:
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

err := shard.Propose(ctx, IntEvent(msg))
if errors.Is(err, dragonboat.ErrShardNotReady) {
log.Println("shard not ready")
} else if err != nil {
return fmt.Errorf("failed to propose event: %w", err)
}
case <-ticker.C:
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Second)
defer cancel()

state, err := shard.Query(ctx, 1)
if err != nil {
return fmt.Errorf("failed to query shard: %w", err)
}
log.Println("state: ", state)
case <-ctx.Done():
return nil
}
}
})

if err := wg.Wait(); err != nil {
kctx.FatalIfErrorf(err)
}
}
1 change: 1 addition & 0 deletions common/internal/tests/testdata/go/omitempty/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions common/internal/tests/testdata/go/runtimereflection/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/cron/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/echo/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/http/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/mysql/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/postgres/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions examples/go/pubsub/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading