go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/nodes/pkg/model/gen/merge.go (about) 1 // File generated by nodegen. DO NOT EDIT. 2 package gen 3 4 import ( 5 "fmt" 6 "time" 7 8 "github.com/wcharczuk/go-incr" 9 "go.charczuk.com/projects/nodes/pkg/funcs" 10 "go.charczuk.com/projects/nodes/pkg/incrutil" 11 "go.charczuk.com/projects/nodes/pkg/types" 12 ) 13 14 func MergeForNode(graph *incr.Graph, n *types.Node) (output incr.INode, err error) { 15 switch n.Metadata.InputType { 16 case "[]bool": 17 switch n.Metadata.OutputType { 18 case "[]bool": 19 output = incrutil.MapN(graph, funcs.MergeMany[[]bool]) 20 return 21 default: 22 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 23 return 24 } 25 26 case "[]float64": 27 switch n.Metadata.OutputType { 28 case "[]float64": 29 output = incrutil.MapN(graph, funcs.MergeMany[[]float64]) 30 return 31 default: 32 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 33 return 34 } 35 36 case "[]int64": 37 switch n.Metadata.OutputType { 38 case "[]int64": 39 output = incrutil.MapN(graph, funcs.MergeMany[[]int64]) 40 return 41 default: 42 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 43 return 44 } 45 46 case "[]string": 47 switch n.Metadata.OutputType { 48 case "[]string": 49 output = incrutil.MapN(graph, funcs.MergeMany[[]string]) 50 return 51 default: 52 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 53 return 54 } 55 56 case "[]duration": 57 switch n.Metadata.OutputType { 58 case "[]duration": 59 output = incrutil.MapN(graph, funcs.MergeMany[[]time.Duration]) 60 return 61 default: 62 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 63 return 64 } 65 66 case "[]timestamp": 67 switch n.Metadata.OutputType { 68 case "[]timestamp": 69 output = incrutil.MapN(graph, funcs.MergeMany[[]time.Time]) 70 return 71 default: 72 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 73 return 74 } 75 76 case "bool": 77 switch n.Metadata.OutputType { 78 case "[]bool": 79 output = incrutil.MapN(graph, funcs.Merge[bool]) 80 return 81 default: 82 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 83 return 84 } 85 86 case "float64": 87 switch n.Metadata.OutputType { 88 case "[]float64": 89 output = incrutil.MapN(graph, funcs.Merge[float64]) 90 return 91 default: 92 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 93 return 94 } 95 96 case "int64": 97 switch n.Metadata.OutputType { 98 case "[]int64": 99 output = incrutil.MapN(graph, funcs.Merge[int64]) 100 return 101 default: 102 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 103 return 104 } 105 106 case "string": 107 switch n.Metadata.OutputType { 108 case "[]string": 109 output = incrutil.MapN(graph, funcs.Merge[string]) 110 return 111 default: 112 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 113 return 114 } 115 116 case "duration": 117 switch n.Metadata.OutputType { 118 case "[]duration": 119 output = incrutil.MapN(graph, funcs.Merge[time.Duration]) 120 return 121 default: 122 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 123 return 124 } 125 126 case "timestamp": 127 switch n.Metadata.OutputType { 128 case "[]timestamp": 129 output = incrutil.MapN(graph, funcs.Merge[time.Time]) 130 return 131 default: 132 err = fmt.Errorf("invalid merge output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 133 return 134 } 135 136 default: 137 err = fmt.Errorf("invalid merge input type %v", n.Metadata.InputType) 138 return 139 } 140 }