Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var JSONToLocalFsCSV = &jetcapture.Options[*ExamplePayload, ExampleDestKey]{ Compression: jetcapture.GZip, Suffix: "csv", MaxAge: time.Hour, MessageDecoder: func(msg *nats.Msg) (*ExamplePayload, ExampleDestKey, error) { var p ExamplePayload if err := json.Unmarshal(msg.Data, &p); err != nil { return nil, "", err } return &p, p.Region, nil }, WriterFactory: func() jetcapture.FormattedDataWriter[*ExamplePayload] { return jetcapture.NewCSVWriter( []string{"first_name", "last_name", "region"}, func(p *ExamplePayload) ([][]string, error) { return [][]string{{ p.FirstName, p.LastName, p.Region, }}, nil }, ) }, Store: &jetcapture.LocalFSStore[ExampleDestKey]{ Resolver: func(dk ExampleDestKey) (string, error) { return filepath.Join("backup", dk), nil }, }, }
JSONToLocalFsCSV is an example configuration that will decode JSON messages that sent over NATS, write them out into CSV files, and group the output into `region` specific folder on the local file system.
Use a pointer to an ExamplePayload as the Payload type parameter and ExampleDestKey as the DestKey type parameter
Functions ¶
This section is empty.
Types ¶
type ExamplePayload ¶
type ExamplePayload struct { FirstName string `json:"first_name"` LastName string `json:"last_name"` Region string `json:"region"` }
ExamplePayload is our explicit struct for the NATS messages
Click to show internal directories.
Click to hide internal directories.