-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* cmd: add basic CLI harness * cmd: wip on server flags * cmd: server: bind flags for event acknowledgement * cmd: server: add kafka client flags * cli: remove usused comments * cmd: simplify boolean flags * cmd: fix --event.ack parsing * config: kafka: make bootstrap server config required * cmd: fix duration flags not propagating values to config * cmd: chore: allow flags on root command * ci: update tests to use raccoon cli * ci: fix compose not starting raccoon server * chore: update config tests * wip: migration to salt/config * config: replace use of time.Duration values with ints This makes it easier to parse data from config files and cli flags * config: WIP validation * config: refactor validation + add fallbacks * docs: kinesis: mark kinesis credentials file required * config: purge utils * chore: tidy deps * config: chore: use consolidate config values * wip: config: salt/config integration * config: refactor config to comply with salt/config * config: revamp error validation * config: fix defaults * config: fix tags on publisher config * config: purge tests * config: add default for server.websocket.conn.group.default * docs: fix ping/pong and write timeout defaults The docs incorrectly specified their values in seconds, when in reality raccoon expects them to be milliseconds * config: move WORKER_KAFKA_DELIVERY_CHANNEL_SIZE to kafka publisher It's now called PUBLISHER_KAFKA_DELIVERY_CHANNEL_SIZE * cmd: server: add flag for config file * config: update cors to use comma separated values * ci: add testing yaml config * chore: add sample raccoon config * cli: integrate salt/cmdx * config: make kafka config type-concrete * misc: fix panic on server shutdown when prometheus metrics are enabled * ci: update test environment * docker: make image act as a CLI * chore: removed unused configs * config: kafka: omit empty configs * cmd: add dynamically generated cli flags * cmd: remove duration flag parser raccoon now uses integer values to represent most duration parameters. * cmd: server: simplify flag parsing
- Loading branch information
Showing
45 changed files
with
2,334 additions
and
834 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM debian:bookworm-slim | ||
WORKDIR /app | ||
COPY raccoon . | ||
CMD ["./raccoon"] | ||
ENTRYPOINT [ "/app/raccoon" ] |
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,43 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/MakeNowJust/heredoc" | ||
"github.com/raystack/salt/cmdx" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func New() *cobra.Command { | ||
root := &cobra.Command{ | ||
Use: "raccoon", | ||
Short: "Scalable event ingestion tool", | ||
SilenceUsage: true, | ||
CompletionOptions: cobra.CompletionOptions{ | ||
DisableDefaultCmd: true, | ||
}, | ||
Args: cobra.NoArgs, | ||
Long: heredoc.Doc(` | ||
Raccoon is a high-throughput, low-latency service to collect | ||
events in real-time from your web, mobile apps, and services | ||
using multiple network protocols.`), | ||
Run: func(cmd *cobra.Command, args []string) { | ||
cmd.Help() | ||
}, | ||
Annotations: map[string]string{ | ||
"group": "core", | ||
"help:learn": heredoc.Doc(` | ||
Use 'raccoon <command> --help' for more information about a command. | ||
Read the manual at https://raystack.github.io/raccoon/ | ||
`), | ||
"help:feedback": heredoc.Doc(` | ||
Open an issue here https://github.com/raystack/raccoon/issues | ||
`), | ||
}, | ||
} | ||
|
||
cmdx.SetHelp(root) | ||
root.AddCommand(cmdx.SetCompletionCmd("raccoon")) | ||
root.AddCommand(cmdx.SetRefCmd(root)) | ||
|
||
root.AddCommand(serverCommand()) | ||
return root | ||
} |
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,90 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"reflect" | ||
"strconv" | ||
|
||
"github.com/raystack/raccoon/app" | ||
"github.com/raystack/raccoon/config" | ||
"github.com/raystack/raccoon/logger" | ||
"github.com/raystack/raccoon/metrics" | ||
"github.com/raystack/raccoon/middleware" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/pflag" | ||
) | ||
|
||
func serverCommand() *cobra.Command { | ||
var configFile = "config.yaml" | ||
command := &cobra.Command{ | ||
Use: "server", | ||
Short: "Start raccoon server", | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
err := config.Load(configFile) | ||
if err != nil { | ||
return err | ||
} | ||
middleware.Load() | ||
metrics.Setup() | ||
defer metrics.Close() | ||
logger.SetLevel(config.Log.Level) | ||
return app.Run() | ||
}, | ||
} | ||
command.Flags().SortFlags = false | ||
command.Flags().StringVarP(&configFile, "config", "c", configFile, "path to config file") | ||
for _, cfg := range config.Walk() { | ||
bindFlag(command.Flags(), cfg.Ref, cfg.Meta) | ||
} | ||
return command | ||
} | ||
|
||
func bindFlag(flag *pflag.FlagSet, ref any, meta reflect.StructField) { | ||
|
||
flagName := meta.Tag.Get("cmdx") | ||
desc := meta.Tag.Get("desc") | ||
|
||
switch v := ref.(type) { | ||
case *config.AckType: | ||
flag.Var(ackTypeFlag{v}, flagName, desc) | ||
case *string: | ||
flag.StringVar(v, flagName, *v, desc) | ||
case *int: | ||
flag.IntVar(v, flagName, *v, desc) | ||
case *int64: | ||
flag.Int64Var(v, flagName, *v, desc) | ||
case *uint32: | ||
flag.Uint32Var(v, flagName, *v, desc) | ||
case *bool: | ||
flag.BoolVar(v, flagName, *v, desc) | ||
case *[]string: | ||
flag.StringSliceVar(v, flagName, *v, desc) | ||
default: | ||
msg := fmt.Sprintf("unsupport flag of type %T", ref) | ||
panic(msg) | ||
} | ||
} | ||
|
||
type ackTypeFlag struct { | ||
value *config.AckType | ||
} | ||
|
||
func (af ackTypeFlag) String() string { | ||
if af.value == nil { | ||
return "0" | ||
} | ||
return fmt.Sprintf("%d", *af.value) | ||
} | ||
|
||
func (af ackTypeFlag) Set(raw string) error { | ||
v, err := strconv.ParseInt(raw, 10, 0) | ||
if err != nil { | ||
return fmt.Errorf("error parsing bool: %w", err) | ||
} | ||
*af.value = config.AckType(v) | ||
return nil | ||
} | ||
|
||
func (af ackTypeFlag) Type() string { | ||
return "int" | ||
} |
Oops, something went wrong.