Skip to content

Commit

Permalink
Complete readme file.
Browse files Browse the repository at this point in the history
  • Loading branch information
iulianp26 committed May 9, 2017
1 parent e158c20 commit 2537fcc
Showing 1 changed file with 163 additions and 52 deletions.
215 changes: 163 additions & 52 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
# next-video-content-collection-mapper
# Next Video Content Collection Mapper
[![Circle CI](https://circleci.com/gh/Financial-Times/upp-next-video-content-collection-mapper/tree/master.png?style=shield)](https://circleci.com/gh/Financial-Times/upp-next-video-content-collection-mapper/tree/master)[![Go Report Card](https://goreportcard.com/badge/github.com/Financial-Times/upp-next-video-content-collection-mapper)](https://goreportcard.com/report/github.com/Financial-Times/upp-next-video-content-collection-mapper) [![Coverage Status](https://coveralls.io/repos/github/Financial-Times/upp-next-video-content-collection-mapper/badge.svg)](https://coveralls.io/github/Financial-Times/upp-next-video-content-collection-mapper)

## Introduction

_What is this service and what is it for? What other services does it depend on_

Get the related content references from the Next video content, creates a story package holding those references and puts a message with them on kafka queue for further processing and ingestion on Neo4j.
Get the related content references from the Next video content ("related" field) by listening to kafka queue, creates a story package holding those references and puts a message with them on kafka queue for further processing and ingestion on Neo4j.

## Installation
_How can I install it_

Download the source code, dependencies and test dependencies:

go get -u github.com/kardianos/govendor
Expand All @@ -20,7 +16,6 @@ Download the source code, dependencies and test dependencies:
go build .

## Running locally
_How can I run it_

1. Run the tests and install the binary:

Expand All @@ -34,47 +29,174 @@ _How can I run it_

Options:

--app-system-code="next-video-content-collection-mapper" System Code of the application ($APP_SYSTEM_CODE)
--app-name="upp-next-video-content-collection-mapper" Application name ($APP_NAME)
--port="8080" Port to listen on ($APP_PORT)
3. Test:
--app-system-code="upp-next-video-content-collection-mapper" System Code of the application ($APP_SYSTEM_CODE)
--app-name="Next Video Content Collection Mapper" Application name ($APP_NAME)
--service-name="next-video-content-collection-mapper" Service name ($SERVICE_NAME)
--port="8080" Port to listen on ($APP_PORT)
--queue-addresses="http://%H:8080" Queue address ($Q_ADDR)
--group="NextVideoContentCollectionMapper" Group used to read messages from queue ($Q_GROUP)
--read-topic="NativeCmsPublicationEvents" Queue topic name from where to read the messages ($Q_READ_TOPIC)
--read-queue="kafka" The queue to read the messages from ($Q_READ_QUEUE)
--write-topic="CmsPublicationEvents" Queue topic name where to write the messages ($Q_WRITE_TOPIC)
--write-queue="kafka" The queue to write the messages to ($Q_WRITE_QUEUE)

1. Either using curl:
There are defaults values used for properties so when deployed locally it can be run the excutable only.

curl http://localhost:8080/people/143ba45c-2fb3-35bc-b227-a6ed80b5c517 | json_pp

1. Or using [httpie](https://github.com/jkbrzt/httpie):
3. Test:

http GET http://localhost:8080/people/143ba45c-2fb3-35bc-b227-a6ed80b5c517
curl http://localhost:8080/__next-video-content-collection-mapper/__health | jq

## Build and deployment
_How can I build and deploy it (lots of this will be links out as the steps will be common)_

* Built by Docker Hub on merge to master: [coco/next-video-content-collection-mapper](https://hub.docker.com/r/coco/next-video-content-collection-mapper/)
* CI provided by CircleCI: [next-video-content-collection-mapper](https://circleci.com/gh/Financial-Times/next-video-content-collection-mapper)
* Built by Docker Hub on merge to master: [coco/next-video-content-collection-mapper](https://hub.docker.com/r/coco/upp-next-video-content-collection-mapper/)
* CI provided by CircleCI: [next-video-content-collection-mapper](https://circleci.com/gh/Financial-Times/upp-next-video-content-collection-mapper)

## Service endpoints
_What are the endpoints offered by the service_

e.g.
### GET

Using curl:

curl http://localhost:8080/people/143ba45c-2fb3-35bc-b227-a6ed80b5c517 | json_pp`

Or using [httpie](https://github.com/jkbrzt/httpie):

http GET http://localhost:8080/people/143ba45c-2fb3-35bc-b227-a6ed80b5c517

The expected response will contain information about the person, and the organisations they are connected to (via memberships).

Based on the following [google doc](https://docs.google.com/document/d/1SC4Uskl-VD78y0lg5H2Gq56VCmM4OFHofZM-OvpsOFo/edit#heading=h.qjo76xuvpj83).


## Utility endpoints
_Endpoints that are there for support or testing, e.g read endpoints on the writers_
### POST

####/map

Example:
`
curl -X POST http://localhost:8080/map -H "Content-Type: application/json" -H "X-Request-Id: tid_12345" -H "X-Origin-System-Id: next-video-editor" -d @body.json
`

body.json:
`
{
"_id": "58d8d6cc789d4c000f6b0169",
"updatedAt": "2017-04-03T16:30:11.106Z",
"createdAt": "2017-03-27T09:09:32.541Z",
"mioId": 762380,
"title": "Trump trade under scrutiny",
"createdBy": "seb.morton-clark",
"encoding": {
"job": 358759376,
"status": "COMPLETE",
"outputs": [{
"audioCodec": "mp3",
"duration": 65904,
"mediaType": "audio/mpeg",
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/0x0.mp3"
},
{
"audioCodec": "aac",
"videoCodec": "h264",
"duration": 65940,
"mediaType": "video/mp4",
"height": 360,
"width": 640,
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/640x360.mp4"
},
{
"audioCodec": "aac",
"videoCodec": "h264",
"duration": 65940,
"mediaType": "video/mp4",
"height": 720,
"width": 1280,
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/1280x720.mp4"
}]
},
"__v": 0,
"byline": "Filmed by Niclola Stansfield. Produced by Seb Morton-Clark.",
"description": "Global equities are on the defensive, led by weaker commodities and financials as investors scrutinise the viability of the Trump trade. The FT's Mike Mackenzie reports.",
"image": "https://api.ft.com/content/ffc60243-2b77-439a-a6c9-0f3603ee5f83",
"standfirst": "Mike Mackenzie provides analysis of the morning's market news",
"updatedBy": "seb.morton-clark",
"isPublished": false,
"related": [{
"id": "c4cde316-128c-11e7-80f4-13e067d5072c",
"title": "Stocks and dollar slide as ‘Trump trade’ fades"
}],
"annotations": [{
"id": "http://api.ft.com/things/059c58aa-53e6-306b-8642-e718c869ec09",
"predicate": "http://www.ft.com/ontology/classification/isPrimarilyClassifiedBy"
},
{
"id": "http://api.ft.com/things/d969d76e-f8f4-34ae-bc38-95cfd0884740",
"predicate": "http://www.ft.com/ontology/classification/isClassifiedBy"
},
{
"id": "http://api.ft.com/things/b43f1a91-b805-3453-8c36-1d164c047ca2",
"predicate": "http://www.ft.com/ontology/annotation/mentions"
},
{
"id": "http://api.ft.com/things/c2acc00f-5ad6-3f79-b6bb-d51dcd81508a",
"predicate": "http://www.ft.com/ontology/annotation/about"
},
{
"id": "http://api.ft.com/things/c2acc00f-5ad6-3f79-b6bb-d51dcd81508a",
"predicate": "http://www.ft.com/ontology/annotation/majorMentions"
}],
"encodings": [{
"mioId": 762380,
"name": "Trump trade under scrutiny",
"primary": true,
"status": "COMPLETE",
"job": 358759376,
"outputs": [{
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/0x0.mp3",
"mediaType": "audio/mpeg",
"duration": 65904,
"audioCodec": "mp3"
},
{
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/640x360.mp4",
"width": 640,
"height": 360,
"mediaType": "video/mp4",
"duration": 65940,
"videoCodec": "h264",
"audioCodec": "aac"
},
{
"url": "http://ftvideo.prod.zencoder.outputs.s3.amazonaws.com/e2290d14-7e80-4db8-a715-949da4de9a07/1280x720.mp4",
"width": 1280,
"height": 720,
"mediaType": "video/mp4",
"duration": 65940,
"videoCodec": "h264",
"audioCodec": "aac"
}]
}],
"canBeSyndicated": true,
"transcription": {
"status": "COMPLETE",
"job": "1579674",
"transcript": "<p>Here's what we're watching with trading underway in London. Global equities under pressure led by weaker commodities and financials as investors scrutinise the viability of the Trump trade. The dollar is weaker. Havens like yen, gold, and government bonds finding buyers. </p><p>As the dust settles over the failure to replace Obamacare, focus now on whether tax reform and other fiscal measures will eventuate. This is where the rubber meets the road for the Trump trade. High flying equity markets had been underpinned by the promise of big tax cuts and fiscal stimulus. And Wall Street is souring. </p><p>One big beneficiary of lower corporate taxes under Trump are small caps. They are now down 2 and 1/2% for the year. While the sector is still much higher since November, this is a key market barometer of prospects for the Trump trade. </p><p>Now while many still think some measure of tax reform or spending will eventuate, markets are very wary, namely of the risk that Congress and the Trump administration fail to reach agreement on legislation, that unlike health care reform, matters a great deal more to investors. </p><p>[MUSIC PLAYING] </p>",
"captions": [{
"format": "vtt",
"url": "https://next-video-editor.ft.com/e2290d14-7e80-4db8-a715-949da4de9a07.vtt",
"mediaType": "text/vtt"
}]
},
"format": [],
"type": "video",
"id": "ad543253-ad5e-471c-a006-ebb395323028"
}
`

Response 200
Body:
`
{
"payload": {
"uuid": "151d4420-6ce6-3964-ad64-916561612973",
"items": [{
"uuid": "c4cde316-128c-11e7-80f4-13e067d5072c"
}],
"publishReference": "tid-12321123",
"type": "story-package"
},
"contentUri": "http://next-video-content-collection-mapper.svc.ft.com/content-collection/story-package/151d4420-6ce6-3964-ad64-916561612973",
"uuid": "151d4420-6ce6-3964-ad64-916561612973"
}
`

Response 400
If the mapping couldn't be performed because of invalid provided content.

## Healthchecks
Admin endpoints are:
Expand All @@ -85,19 +207,8 @@ Admin endpoints are:

`/__build-info`

_These standard endpoints do not need to be specifically documented._

_This section *should* however explain what checks are done to determine health and gtg status._

There are several checks performed:

_e.g._
* Checks that a connection can be made to Neo4j, using the neo4j url supplied as a parameter in service startup.

## Other information
_Anything else you want to add._

_e.g. (NB: this example may be something we want to extract as it's probably common to a lot of services)_
Following check is performed for health and gtg endpoints:
* Checks that the connection to queue can be established.

### Logging

Expand Down

0 comments on commit 2537fcc

Please sign in to comment.