Releases: src-d/lookout-sdk
v0.6.3
v0.6.2
v0.6.1
New Features
This release includes the following:
Audit trail for GetChanges
and GetFiles
calls
The SDK library now provides a mechanism to keep log fields during the message exchange between lookoutd
and your analyzer.
An example of the logs fields that are kept in the message exchange would be:
{
"repository": "github.com/src-d/lookout-sdk",
"github.pr": 17
}
In practice this means that your analyzer will be able to easily add relevant information to its logs, and lookoutd
will have a context for each call you make. A sort of audit trail for each GetChanges
or GetFiles
call.
This mechanism is implemented differently in the Go SDK and in the Python SDK
Go SDK
The above mentioned mechanism is implemented by using gRPC interceptors:
pb.CtxlogUnaryClientInterceptor
,pb.CtxlogStreamClientInterceptor
,pb.CtxlogUnaryServerInterceptor
,pb.CtxlogStreamServerInterceptor
.
These interceptors are added automatically using pb.DialContext
and pb.NewServer
. There are also pb.DialContextWithInterceptors
and pb.NewServerWithInterceptors
respectively in case you want to add other interceptors. See examples/language-analyzer.go
.
In your analyzer you can then use the pb.GetLogFields
and pb.AddLogFields
to read and add log fields to the context. The log fields that you add will be available to lookoutd
.
Python SDK
The above mentioned mechanism is implemented by passing a wrapped context to each analyzer call (Notify{Review,Push}Event
), and by changing the base class of your analyzer:
- in version v0.5.0:
lookout.sdk.pb.AnalyzerServicer
->lookout.sdk.service_analyzer_pb2_grpc.AnalyzerServicer
,
in version v0.6.1:lookout.sdk.pb.AnalyzerServicer
->lookout.sdk.service_analyzer.AnalyzerServicer
.
The wrapped context is a proxy to the gRPC one. It additionally provides functionalities for adding and reading log fields that will be available to lookoutd
, once you "activate" the audit trail (see later). See lookout.sdk.grpc.log_fields.LogFieldsContext
.
This change is not a breaking change. Without updating anything the code is expected to work as before the update. In order to "activate" the audit trail you have to follow some steps. See the migration guide.
Logger interceptors
The SDK library now provides gRPC interceptors both for Go SDK and Python SDK for logging client calls and server request. See examples/language-analyzer.go
and examples/language-analyzer.py
to see how to use them.
Python SDK
An extra note must be added for the Python SDK. At time of writing gRPC for Python doesn't provide an api to add server interceptors for diffenret method types, so an api on top of that has been added to provide the user the capability to also add custom server interceptors. See lookout.sdk.grpc.interceptors.base
.
[Python SDK] Default message size for gRPC server
A new create_server
function creates a server with default values for gRPC max send and max receive message length.
Migration Guide: v0.5.0 => v0.6.1
You might want to check out the changes made to examples/language-analyzer.go
and examples/language-analyzer.py
in the comparison view.
Go SDK
Except for using pb.DialContext
and pb.NewServer
or their corresponding pb.DialContextWithInterceptors
and pb.NewServerWithInterceptors
, you don't have anything else to do in order to activate the audit trail.
Python SDK
Follow these steps to activate the audit trail.
- Rename the following:
NotifyReviewEvent
->notify_review_event
,NotifyPushEvent
->notify_push_event
.
- Use
create_server
. - Use
DataStub
imported fromlookout.sdk.service_data
and not frompb
. The returned stub has a more pythonic api. You have to rename the following calls:GetChanges
->get_changes
,GetFiles
->get_files
.
Both methods needs as first positional argument the context.
v0.6.0
Not recommended
This release brings new functionality that breaks compatibility with v0.5.0
. Please use the v0.6.1 release instead, that includes the same new features but in a backwards-compatible way.
Breaking Changes
#71: The SDK library now applies gRPC interceptors to the gRPC client and server. These connectors allow to keep log fields during the message exchange between lookoutd
and your analyzer.
An example of the logs fields that are kept in the message exchange would be
{
"repository": "github.com/src-d/lookout-sdk",
"github.pr": 17
}
In practice this means that your analyzer will be able to add relevant information to its logs; and lookoutd
will have a context for each call you make. A sort of audit trail for each GetChanges
or GetFiles
call.
You might want to check out the changes made to examples/language-analyzer.go
and examples/language-analyzer.py
in the comparison view.
v0.5.0
Breaking Changes
This release removes the merge
field from ReviewEvent
(#74).
When a pull request is created on GitHub, they create a merge commit to test whether the head branch can be automatically merged into the base branch. The merge
field stored a reference pointer to this merge.
This field is specific to GitHub, and is only present when the pull request is mergeable. We have removed it to make the SDK easier to use.
v0.4.1
New Features
Go
- In previous versions we instructed analyzer authors to disable secure connections to source{d} Lookout using
grpc.WithInsecure()
. This is not needed anymore because the SDK library performs it when you usepb.DialContext
(#67). - New instructions to use
conn.ResetConnectBackoff
to reset the gRPC backoff when your analyzer receives a new event. See the documentation here (#66).
Python
- The library is now also published as a Source Distribution, sdist (#68).
v0.3.1
This release includes more comprehensive documentation for the .proto
files and the GoDoc reference.
v0.3.0
New Features
- New field
include_languages
forChangesRequest
andFilesRequest
protobuf messages (#36).
Python
- Don't import anything grpc related in
sdk/__init__
, usesdk/pb.py
instead (#43). - Add package to namespace
lokoout
(#48). - Define package version in
sdk/__init__.py
__version__
(#55). - Use a range instead of a fixed version for
grpcio
dependency (#54).