Skip to content

Commit

Permalink
move options up from under sf.substreams.v1, cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
sduchesneau committed Sep 21, 2023
1 parent d079e63 commit deb3a28
Show file tree
Hide file tree
Showing 9 changed files with 230 additions and 234 deletions.
8 changes: 6 additions & 2 deletions docs/release-notes/change-log.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
Example:
```
import "sf/substreams/v1/options.proto";
optional bytes schema = 1 [ (sf.substreams.v1.options).load_from_file = true ];`
optional bytes extra_config_files = 2 [ (sf.substreams.v1.options).zip_from_folder = true ];`
message HostedPostgresDatabase {
bytes schema = 1 [ (sf.substreams.v1.options).load_from_file = true ];
bytes extra_config_files = 2 [ (sf.substreams.v1.options).zip_from_folder = true ];
}
```

* `substreams info` command now properly displays the sink configs, optionally writing the bytes fields to disk with `--dump-sinkconfig-bytes-to-disk` flag

### Removed
Expand Down
28 changes: 10 additions & 18 deletions manifest/sink.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/jhump/protoreflect/desc"
"github.com/jhump/protoreflect/dynamic"
"go.uber.org/zap"
"google.golang.org/protobuf/reflect/protoreflect"
"google.golang.org/protobuf/types/descriptorpb"
"google.golang.org/protobuf/types/known/anypb"

Expand Down Expand Up @@ -91,15 +90,9 @@ func SinkConfigAsString(pkg *pbsubstreams.Package, dumpBytesToDisk bool) (string
key: fd.GetJSONName(),
}
if opts := fd.GetFieldOptions(); opts != nil {
opts.ProtoReflect().Range(func(desc protoreflect.FieldDescriptor, val protoreflect.Value) bool {
if desc.TextName() != "[sf.substreams.v1.options]" {
return true
}
opts := val.Message().Interface().(*pbsubstreams.FieldOptions)
field.opts = opts

return true
})
if val := opts.ProtoReflect().Get(pbsubstreams.E_Options.TypeDescriptor()); val.IsValid() {

Check failure on line 93 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / build-and-push-image

undefined: pbsubstreams.E_Options

Check failure on line 93 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, ubuntu-latest)

undefined: pbsubstreams.E_Options

Check failure on line 93 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, macos-latest)

undefined: pbsubstreams.E_Options
field.opts = val.Message().Interface().(*pbsubstreams.FieldOptions)

Check failure on line 94 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / build-and-push-image

undefined: pbsubstreams.FieldOptions

Check failure on line 94 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, ubuntu-latest)

undefined: pbsubstreams.FieldOptions

Check failure on line 94 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, macos-latest)

undefined: pbsubstreams.FieldOptions
}
}
val, err := dynMsg.TryGetField(fd)
if err != nil {
Expand Down Expand Up @@ -139,7 +132,7 @@ func (f *fieldAndValue) String(dumpBytesToDisk bool) string {
if _, err := file.Write(val); err != nil {
zlog.Error("writing data to file", zap.Error(err))
}
suffix += " -> written to " + file.Name()
suffix += " -> written to " + file.Name()
}

return fmt.Sprintf(" - %v: (%d bytes) MD5SUM: %v %v", f.key, len(val), sum, suffix)
Expand Down Expand Up @@ -168,13 +161,9 @@ func fieldResolver(msgDesc *desc.MessageDescriptor) func(string) (opts *pbsubstr
if fd.GetFullyQualifiedJSONName() == fqdn {
isBytes := fd.GetType() == descriptorpb.FieldDescriptorProto_TYPE_BYTES
if opts := fd.GetFieldOptions(); opts != nil {
opts.ProtoReflect().Range(func(desc protoreflect.FieldDescriptor, val protoreflect.Value) bool {
if desc.TextName() != "[sf.substreams.v1.options]" {
return true
}
if val := opts.ProtoReflect().Get(pbsubstreams.E_Options.TypeDescriptor()); val.IsValid() {

Check failure on line 164 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / build-and-push-image

undefined: pbsubstreams.E_Options

Check failure on line 164 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, ubuntu-latest)

undefined: pbsubstreams.E_Options

Check failure on line 164 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, macos-latest)

undefined: pbsubstreams.E_Options
options = val.Message().Interface().(*pbsubstreams.FieldOptions)

Check failure on line 165 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / build-and-push-image

undefined: pbsubstreams.FieldOptions

Check failure on line 165 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, ubuntu-latest)

undefined: pbsubstreams.FieldOptions

Check failure on line 165 in manifest/sink.go

View workflow job for this annotation

GitHub Actions / Test (1.21.x, macos-latest)

undefined: pbsubstreams.FieldOptions
return false
})
}
}
return options, isBytes
}
Expand Down Expand Up @@ -300,7 +289,10 @@ func addFiles(w *zip.Writer, basePath string) error {
if err != nil {
return err
}
path = strings.Replace(strings.TrimPrefix(strings.TrimPrefix(path, basePath), string(filepath.Separator)), "\\", "/", -1)

path = strings.TrimPrefix(path, basePath) // relative path
path = strings.TrimPrefix(path, string(filepath.Separator)) // ensure we don't start with a slash
path = strings.Replace(path, "\\", "/", -1) // w.Create does not support windows-style separators

if info.IsDir() {
path += fmt.Sprintf("%s%c", path, os.PathSeparator)
Expand Down
2 changes: 1 addition & 1 deletion pb/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ function generate_system() {
fi

protoc -I$PROTO \
"$PROTO/sf/substreams/options.proto" \
"$PROTO/sf/substreams/v1/modules.proto" \
"$PROTO/sf/substreams/v1/package.proto" \
"$PROTO/sf/substreams/v1/options.proto" \
"$PROTO/sf/substreams/v1/clock.proto" \
"$PROTO/sf/substreams/rpc/v2/service.proto" \
"$PROTO/google/protobuf/any.proto" \
Expand Down
4 changes: 2 additions & 2 deletions pb/last_generate.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
generate.sh - Mon 18 Sep 2023 15:04:30 EDT - stepd
streamingfast/proto revision: 2899868ddee59b2d3d398dffa99561c7a84c8c37
generate.sh - Thu 21 Sep 2023 14:20:48 EDT - stepd
streamingfast/proto revision: d079e6342b6e1a9297b594476dedf98b0d82e0a8
192 changes: 192 additions & 0 deletions pb/sf/substreams/options.pb.go

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

Loading

0 comments on commit deb3a28

Please sign in to comment.