Code Monkey home page Code Monkey logo

auditing-thrift-model's Introduction

Thrift model for auditing updates

How to use

Scala

in build.sbt

libraryDependencies ++= Seq(
    "com.gu" %% "auditing-thrift-model" % "0.3.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

auditing-thrift-model's People

Contributors

reettaphant avatar itsibitzi avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.