Skip to content

Commit

Permalink
strip proto pkg name prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeless committed Dec 12, 2023
1 parent 95496e9 commit 217d8cf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion service/tier1.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ func getBlockTypeFromStreamFactory(sf *StreamFactory) (string, error) {
return "", err
}
}
return out, nil

return strings.TrimPrefix(out, protoPkfPrefix), nil
}

func NewTier1(
Expand Down
7 changes: 5 additions & 2 deletions service/tier2.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"io"
"os"
"strings"

"github.com/bufbuild/connect-go"
"github.com/streamingfast/bstream"
Expand Down Expand Up @@ -43,18 +44,20 @@ type Tier2Service struct {
logger *zap.Logger
}

const protoPkfPrefix = "type.googleapis.com/"

func getBlockTypeFromMergedBlocks(store dstore.Store) (string, error) {
var out string
fs := bstream.NewFileSource(store, bstream.GetProtocolFirstStreamableBlock, bstream.HandlerFunc(func(blk *pbbstream.Block, obj interface{}) error {
out = blk.Payload.TypeUrl
return io.EOF
}), zlog)

fs.Run()

if err := fs.Err(); err != io.EOF {
return "", err
}
return out, nil
return strings.TrimPrefix(out, protoPkfPrefix), nil
}

func NewTier2(
Expand Down

0 comments on commit 217d8cf

Please sign in to comment.