BinaryHandler creates a new stream processor handler which calls out to the given binary. The id is used to identify the stream processor and allows the caller to send payloads specific for that stream processor (i.e. decryption keys for decrypt stream processor). The binary will be called for the p
(id, returnsMediaType string, mediaTypes []string, path string, args, env []string)
| 173 | // payloads specific for that stream processor (i.e. decryption keys for decrypt stream processor). |
| 174 | // The binary will be called for the provided mediaTypes and return the given media type. |
| 175 | func BinaryHandler(id, returnsMediaType string, mediaTypes []string, path string, args, env []string) Handler { |
| 176 | set := make(map[string]struct{}, len(mediaTypes)) |
| 177 | for _, m := range mediaTypes { |
| 178 | set[m] = struct{}{} |
| 179 | } |
| 180 | return func(_ context.Context, mediaType string) (StreamProcessorInit, bool) { |
| 181 | if _, ok := set[mediaType]; ok { |
| 182 | return func(ctx context.Context, stream StreamProcessor, payloads map[string]typeurl.Any) (StreamProcessor, error) { |
| 183 | payload := payloads[id] |
| 184 | return NewBinaryProcessor(ctx, mediaType, returnsMediaType, stream, path, args, env, payload) |
| 185 | }, true |
| 186 | } |
| 187 | return nil, false |
| 188 | } |
| 189 | } |
| 190 | |
| 191 | const mediaTypeEnvVar = "STREAM_PROCESSOR_MEDIATYPE" |
no test coverage detected
searching dependent graphs…