auditing-thrift-model

Thrift model for auditing updates

License

License

GroupId

GroupId

com.gu
ArtifactId

ArtifactId

auditing-thrift-model_2.10
Last Version

Last Version

0.4
Release Date

Release Date

Type

Type

jar
Description

Description

auditing-thrift-model
Thrift model for auditing updates
Project URL

Project URL

https://github.com/guardian/auditing-thrift-model
Project Organization

Project Organization

com.gu
Source Code Management

Source Code Management

https://github.com/guardian/auditing-thrift-model

Download auditing-thrift-model_2.10

How to add to project

<!-- https://jarcasting.com/artifacts/com.gu/auditing-thrift-model_2.10/ -->
<dependency>
    <groupId>com.gu</groupId>
    <artifactId>auditing-thrift-model_2.10</artifactId>
    <version>0.4</version>
</dependency>
// https://jarcasting.com/artifacts/com.gu/auditing-thrift-model_2.10/
implementation 'com.gu:auditing-thrift-model_2.10:0.4'
// https://jarcasting.com/artifacts/com.gu/auditing-thrift-model_2.10/
implementation ("com.gu:auditing-thrift-model_2.10:0.4")
'com.gu:auditing-thrift-model_2.10:jar:0.4'
<dependency org="com.gu" name="auditing-thrift-model_2.10" rev="0.4">
  <artifact name="auditing-thrift-model_2.10" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.gu', module='auditing-thrift-model_2.10', version='0.4')
)
libraryDependencies += "com.gu" % "auditing-thrift-model_2.10" % "0.4"
[com.gu/auditing-thrift-model_2.10 "0.4"]

Dependencies

compile (3)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.10.6
org.apache.thrift : libthrift jar 0.9.3
com.twitter : scrooge-core_2.10 jar 4.3.0

Project Modules

There are no modules declared in this project.

Thrift model for auditing updates

How to use

Scala

in build.sbt

libraryDependencies ++= Seq(
    "com.gu" %% "auditing-thrift-model" % "0.4.0"
)

somewhere in your code

import com.gu.auditing.model.v1.{App, Notification}

Notification(
    app = App.YourAppHere,
    operation = "EatFruit",
    userEmail = "[email protected]",
    date = new DateTime().toString(),
    resourceId = Some("apple"),
    message = Some("{json}")
)))

node.js

You'll probably want to use thrift-serializer to handle the messages.

Sending messages

var Notification = require('auditing-thrift-model').Notification;
var App = require('auditing-thrift-model').App;

var message = new Notification({
    app = App.YourAppHere,
    operation = "EatFruit",
    userEmail = "[email protected]",
    date = (new Date()).toISOString(),
    resourceId = "apple",
    message = JSON.stringify({json})
});

serializer.write(message, serializer.Compression.Gzip, function (err, bytes) {
    // use the buffer somehow
});

Receiving notifications

var serializer = require('thrift-serialize');
var Notification = require('auditing-thrift-model').Notification;

serializer.read(Notification, data, function (err, message) {
    console.log(message.operation, message.date);
    // You can have the full name of the source app calling
    console.log(message.getAppName());
});

Develop

Prerequisites

  • Install thrift using brew install thrift

Add an application

The list of allowed applications is kept as an enum, add new ones in App.

Release

The model is used both by Scala applications and node.js lambda.

  • sbt release to publish a new version on Sonatype
  • npm run compile to compile the model for node.js
  • update the version of package.json it should match the one you just released on Sonatype
  • npm publish ./ to publish the new version on npm
com.gu

The Guardian

The source code of the world's leading liberal voice

Versions

Version
0.4
0.3.0
0.2
0.1.0
0.0.2
0.0.1