github micro/go-micro v0.20.0
0.20.0 - Breaking Changes

latest releases: v5.3.0, v5.2.0, v5.1.0...
5 years ago

BREAKING CHANGES

Codec

Do not move to this tag unless you're willing to incur the breaking changes.
This changes the default codec to raw protobuf and switches the content-type
application/octet-stream to use the bytes codec also. This breaking change
affects any previous use.

To explicitly be backwards compatible do the following.

In the server

// Process octet-stream as proto-rpc in the old ways
server.DefaultCodecs["application/octet-stream"] = protorpc.NewCodec
// Process json in the old way
server.DefaultCodecs["application/json"] = jsonrpc.NewCodec
// Process protobuf in the old way
server.DefaultCodecs["application/protobuf"] = protorpc.NewCodec

In the client

// In the client send proto-rpc to be forwards compatible
client.DefaultContentType = "application/proto-rpc"

There are changes to application/json and application/protobuf to use raw formats
rather than json-rpc or proto-rpc. This will likely break behaviour via the api.
The easiest way to resolve this is to reset these as well but it causes further issue.

I would advise finding a common rolling path forward e.g a common compatible content-type/codec.

This is an unfortunate change that has to be made so we can process raw formats.

The old list of codecs and can be set as follows

import (
        "github.com/micro/go-micro/server"
        "github.com/micro/go-micro/client"
)

func init() {
	codecs = map[string]codec.NewCodec{
		"application/json":         jsonrpc.NewCodec,
		"application/json-rpc":     jsonrpc.NewCodec,
		"application/protobuf":     protorpc.NewCodec,
		"application/proto-rpc":    protorpc.NewCodec,
		"application/octet-stream": protorpc.NewCodec,
	}
        server.DefaultCodecs = codecs
        client.DefaultCodecs = codecs
)

Endpoint

Method now moves to endpoint. In most places we have Endpoint specified except in the client/server abstractions.
This has now moved. Most should be unaffected. But be aware of the change. Any wrappers may break.

Don't miss a new go-micro release

NewReleases is sending notifications on new releases.