11package core
22
33import (
4+ "bytes"
45 "errors"
56 "fmt"
67 "io"
@@ -83,6 +84,7 @@ type DataStreamFactory struct {
8384 SourcePath string
8485 SourceProvider any
8586 Reader io.Reader
87+ Length int64
8688}
8789
8890func (dsf * DataStreamFactory ) CloseStream () error {
@@ -93,6 +95,25 @@ func (dsf *DataStreamFactory) CloseStreamAndIgnoreError() {
9395 _ = dsf .CloseStream ()
9496}
9597
98+ func GetReaderLength (r io.Reader ) int64 {
99+ switch v := r .(type ) {
100+ case * bytes.Buffer :
101+ return int64 (v .Len ())
102+ case * bytes.Reader :
103+ return int64 (v .Len ())
104+ case * strings.Reader :
105+ return int64 (v .Len ())
106+ case * os.File :
107+ stat , err := v .Stat ()
108+ if err != nil {
109+ return 0
110+ }
111+ return stat .Size ()
112+ default :
113+ return - 1
114+ }
115+ }
116+
96117var (
97118 onceReIsExec sync.Once
98119 reIsExec * regexp.Regexp
@@ -130,9 +151,11 @@ type NodeBaseInterface interface {
130151 SetId (id string )
131152 GetNodeTypeId () string
132153 GetName () string
154+ GetLabel () string
133155 GetId () string
134156 GetCacheId () string
135157 SetName (name string )
158+ SetLabel (label string )
136159 GetGraph () * ActionGraph
137160
138161 // Instead of checking for 'HasExecutionInterface',
@@ -151,6 +174,7 @@ type NodeBaseInterface interface {
151174// The node that implements this component has outgoing connections.
152175type NodeBaseComponent struct {
153176 Name string // Human readable name of the node
177+ Label string // Label of the node shown in the graph editor
154178 Id string // Unique identifier for the node
155179 FullPath string // Full path of the node within the graph hierarchy
156180 CacheId string // Unique identifier for the cache
@@ -221,10 +245,18 @@ func (n *NodeBaseComponent) GetName() string {
221245 return n .Name
222246}
223247
248+ func (n * NodeBaseComponent ) GetLabel () string {
249+ return n .Label
250+ }
251+
224252func (n * NodeBaseComponent ) SetName (name string ) {
225253 n .Name = name
226254}
227255
256+ func (n * NodeBaseComponent ) SetLabel (label string ) {
257+ n .Label = label
258+ }
259+
228260func IsValidIndexPortId (id string ) (string , int , bool ) {
229261 indexPortMatch := getIndexPortRegex ().FindStringSubmatch (id )
230262 if len (indexPortMatch ) < 3 {
0 commit comments