ext_compressor.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2023 EMQ Technologies Co., Ltd.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. //go:build compression || !core
  15. package compressor
  16. import (
  17. "github.com/lf-edge/ekuiper/internal/compressor/flate"
  18. "github.com/lf-edge/ekuiper/internal/compressor/gzip"
  19. "github.com/lf-edge/ekuiper/internal/compressor/zlib"
  20. "github.com/lf-edge/ekuiper/internal/compressor/zstd"
  21. "github.com/lf-edge/ekuiper/pkg/message"
  22. )
  23. const (
  24. ZLIB = "zlib"
  25. GZIP = "gzip"
  26. FLATE = "flate"
  27. ZSTD = "zstd"
  28. )
  29. func init() {
  30. compressors[ZLIB] = func(name string) (message.Compressor, error) {
  31. return zlib.NewZlibCompressor()
  32. }
  33. compressors[GZIP] = func(name string) (message.Compressor, error) {
  34. return gzip.NewGzipCompressor()
  35. }
  36. compressors[FLATE] = func(name string) (message.Compressor, error) {
  37. return flate.NewFlateCompressor()
  38. }
  39. compressors[ZSTD] = func(name string) (message.Compressor, error) {
  40. return zstd.NewZstdCompressor()
  41. }
  42. compressWriters[GZIP] = gzip.NewWriter
  43. compressWriters[ZSTD] = zstd.NewWriter
  44. }