yarpcsnappy

package
v1.47.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 16, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package yarpcsnappy provides a YARPC binding for snappy compression.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Compressor

type Compressor struct {
	// contains filtered or unexported fields
}

Compressor represents the snappy streaming compression strategy.

func New

func New(...Option) *Compressor

New returns a Snappy compression strategy, suitable for configuring an outbound dialer.

The compressor is compatible with the gRPC experimental compressor system. However, since gRPC requires global registration of compressors, you must arrange for the compressor to be registered in your application initialization.

import (
    "google.golang.org/grpc/encoding"
    "go.uber.org/yarpc/compressor/grpc"
    "go.uber.org/yarpc/compressor/snappy"
)

var SnappyCompressor = yarpcsnappy.New()

func init()
    sc := yarpcgrpccompressor.New(SnappyCompressor)
    encoding.RegisterCompressor(sc)
}

If you are constructing your YARPC clients directly through the API, create a gRPC dialer with the Compressor option.

trans := grpc.NewTransport()
dialer := trans.NewDialer(grpc.Compressor(SnappyCompressor))
peers := roundrobin.New(dialer)
outbound := trans.NewOutbound(peers)

If you are using the YARPC configurator to create YARPC objects using config files, you will also need to register the compressor with your configurator.

configurator := yarpcconfig.New()
configurator.MustRegisterCompressor(SnappyCompressor)

Then, using the compression strategy for outbound requests on a particular client, just set the compressor to snappy.

outbounds:
  theirsecureservice:
    grpc:
      address: ":443"
      tls:
        enabled: true
      compressor: snappy

func (*Compressor) Compress

func (c *Compressor) Compress(w io.Writer) (io.WriteCloser, error)

Compress creates a snappy compressor.

func (*Compressor) Decompress

func (c *Compressor) Decompress(r io.Reader) (io.ReadCloser, error)

Decompress creates a snappy decompressor.

func (*Compressor) Name

func (*Compressor) Name() string

Name is snappy.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an option argument for the Snappy compressor constructor, New.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL