content-collection-unfolder
10K+
UPP Service that finds added/deleted collection members and lead article through relations-api. Then it forwards mapped content collections to the content-collection-rw-neo4j to be written in Neo4j database. If a 200 answer is received from the writer, it retrieves the added/deleted contents and the lead article in the collection from document-store-api and then places them in Kafka on the Post Publication topic so that notifications will be created for them.
Dependencies are:
Download the source code, dependencies and test dependencies:
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
go get -u github.com/Financial-Times/content-collection-unfolder
cd $GOPATH/src/github.com/Financial-Times/content-collection-unfolder
dep ensure -vendor-only
go build .
Run the tests and install the binary:
dep ensure -vendor-only
go test -v -race ./...
go install
Run the binary (using the help flag to see the available optional arguments):
$GOPATH/bin/content-collection-unfolder [--help]
Options:
--app-system-code="content-collection-unfolder" System Code of the application ($APP_SYSTEM_CODE)
--app-name="Content Collection Unfolder" Application name ($APP_NAME)
--app-port="8080" Port to listen on ($APP_PORT)
--unfolding-whitelist=["content-package"] Collection types for which the unfolding process should be performed ($UNFOLDING_WHITELIST)
--writer-uri="http://localhost:8080/__content-collection-rw-neo4j/content-collection/" URI of the Writer ($WRITER_URI)
--writer-health-uri="http://localhost:8080/__content-collection-rw-neo4j/__health" URI of the Writer health endpoint ($WRITER_HEALTH_URI)
--content-resolver-uri="http://localhost:8080/__document-store-api/content/" URI of the Content Resolver ($CONTENT_RESOLVER_URI)
--content-resolver-health-uri="http://localhost:8080/__document-store-api/__health" URI of the Content Resolver health endpoint ($CONTENT_RESOLVER_HEALTH_URI)
--relations-resolver-uri="http://localhost:8080/__relations-api/contentcollection/{uuid}/relations" \ URI of the Relations Resolver ($RELATIONS_RESOLVER_URI)
--relations-resolver-health-uri="http://localhost:8080/__relations-api/__health" \ URI of the Relations Resolver health endpoint ($RELATIONS_RESOLVER_HEALTH_URI)
--kafka-write-topic="PostPublicationEvents" The topic to write the messages to ($Q_WRITE_TOPIC)
--kafka-proxy-address="http://localhost:8080" Addresses of the kafka proxy ($Q_ADDR)
--kafka-proxy-hostname="kafka" The hostname of the kafka proxy (for hostname based routing) ($Q_HOSTNAME)
--kafka-authorization="" Authorization for kafka ($Q_AUTHORIZATION)
3. Test:
Create a file with the following content collection contents:
{
"uuid": "45163790-eec9-11e6-abbc-ee7d9c5b3b90",
"items": [
{
"uuid": "d4986a58-de3b-11e6-86ac-f253db7791c6"
},
{
"uuid": "d9b4c4c6-dcc6-11e6-86ac-f253db7791c6"
}
],
"publishReference": "tdi23377744",
"lastModified": "2017-01-31T15:33:21.687Z"
}
Assuming that the file you just is cc.json, you can run the following curl command to test the unfolder
curl -X PUT --data "@cc.json" localhost:8080/content-collection/content-package/45163790-eec9-11e6-abbc-ee7d9c5b3b90
If you've setup everything correctly, you should receive a 200 response. You can also watch the app logs for errors as the
unfolder will return a 200 even if kafka related processing fails.
How can I build and deploy it (lots of this will be links out as the steps will be common)
Using curl:
curl -X PUT --data "@cc.json" localhost:8080/content-collection/content-package/45163790-eec9-11e6-abbc-ee7d9c5b3b90
The expected response is a simple 200 with no response body. In case a error takes place, a json response body will be provided,
similar to the following example:
{"msg\":"Something bad happened"}
As a rule of thumb, the unfolder will return the exact response status code and body received from the content-collection-neo4j-rw app in
case a non 200 response is received.
The flow of the unfolder is the following:
200 response, the writer response is sent to the unfolder clientcontent-package is unfolded), a 200 response is returnedAdmin endpoints are:
/__gtg
/__build-info
/__ping
/__health
There are following checks are performed when the /__health is called:
The /__gtg endpoint will return a 200 in case all above health checks are successful.
Content type
Image
Digest
Size
3 MB
Last updated
about 6 years ago
docker pull coco/content-collection-unfolder