KrakenD catchall path - microservices

I have two paths in KrakenD config: /city/toronto and /city/vancouver. I want to create another path /city/other that would catch every other city that would be provided.
I know at first glance one would say: make the city a path parameter or one would even say make the city a query parameter. I have considered these options and they are not viable.
Is there a way in Krakend To define a catchall or fallback endpoint? I though wildcard could allow me to do this but I am not seeing how this would work.

In earlier versions of KrakenD this was not possible, but since 1.4 you can use routes that before were considered to be conflicting. The following example does exactly what you are expecting. Run with the -d flag:
krakend run -d -c krakend.json where the content of the JSON file is:
{
"version": 2,
"endpoints": [
{
"endpoint": "/city/vancouver",
"backend": [
{
"url_pattern": "/__debug/vancouver",
"host": [
"http://localhost:8080"
]
}
]
},
{
"endpoint": "/city/toronto",
"backend": [
{
"url_pattern": "/__debug/toronto",
"host": [
"http://localhost:8080"
]
}
]
},
{
"endpoint": "/city/{other}",
"backend": [
{
"url_pattern": "/__debug/catchall",
"host": [
"http://localhost:8080"
]
}
]
}
]
}

Related

How do I get custom metrics done in micrometer to graphite?

Similar to How to get Micrometer to output all custom metrics but I am trying to do it for Graphite.
I have a custom metric counter defined as:
#Bean
Counter successfulAuthenticationRequests(MeterRegistry meterRegistry) {
return Counter.builder(metricPrefix + ".auth.authentication.success")
.tag("group", "authentication")
.tag("state", "ok")
.register(meterRegistry);
}
In actuator I can see the value
❯ curl http://localhost:28082/actuator/metrics/spring.cloud.gateway.auth.authentication.success | jq
{
"name": "spring.cloud.gateway.auth.authentication.success",
"measurements": [
{
"statistic": "COUNT",
"value": 2
}
],
"availableTags": [
{
"tag": "node",
"values": [
"docker-desktop"
]
},
{
"tag": "service",
"values": [
"ds_gateway"
]
},
{
"tag": "state",
"values": [
"ok"
]
},
{
"tag": "group",
"values": [
"authentication"
]
}
]
}
The environment is set up as
management.graphite.metrics.export.host: graphite
management.graphite.metrics.export.enabled: "true"
management.graphite.metrics.export.port: 2004
And I can see that there's data added to Graphite so I presume the connection is all valid.
However, I can't see my custom counter. I tried to use a different prefix as well and none of it worked.
Is there anything I may be missing?
I also tried to disable tag support by adding
management.graphite.metrics.export.graphiteTagsEnabled: "false"
I get more metrics with this set in Spring but not for my custom metrics.

FHIR - Contained Resources and Referencing

I am still new to FHIR and trying to connect the dots.
If I have a resource that I want to contain other resources, can I refer to it by element name (#myElementName) or do I need to use the contained resource id? (#myDeviceId).
I've included sample code below. What I would like to accomplish is to have a Basic resource that has two extensions: TestConfiguration(Device) and DigitalSample(ImagingStudy). I would like for both of these resources to be contained.
PS: I generated the code below using custom classes and the .net API.
Thank you much!
{
"resourceType": "TestInput",
"contained": [
{
"resourceType": "TestConfiguration",
"id": "TestConfigurationId",
"contained": [
{
"resourceType": "DeviceDefinition",
"modelNumber": "ABC123"
}
],
"definition": {
"reference": "#definition"
}
},
{
"resourceType": "DigitalSample",
"id": "DigitalSampleId"
}
],
"extension": [
{
"url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-TestConfiguration",
"valueReference": {
"reference": "#testConfiguration"
}
},
{
"url": "http://MyOrganization.com/fhir/R4/StructureDefinition/Basic-DigitalSample",
"valueReference": {
"reference": "#digitalSampleId"
}
}
]
}
Every local reference must point to an id of a contained resource.
In your case it should be:
"reference": "#TestConfigurationId"
"reference":"#DigitalSampleId"
Always check https://www.hl7.org/fhir/ for what you need to do. Always check the FHIR version

Missing elements for a Google Cloud Video Annotation request

I am trying to run annotation on a video using the Google Cloud Video Intelligence API. Annotation requests with just one feature request (i.e., one of "LABEL_DETECTION", "SHOT_CHANGE_DETECTION" or "EXPLICIT_CONTENT_DETECTION"), things work fine. However, when I request an annotation with two or more features at the same time, the response does not always return all the request feature fields. For example, here is a request I ran recently using the API explorer:
{
"features": [
"EXPLICIT_CONTENT_DETECTION",
"LABEL_DETECTION",
"SHOT_CHANGE_DETECTION"
],
"inputUri": "gs://gccl_dd_01/Video1"
}
The operation Id I got back is this: "us-east1.11264560501473964275". When I run a GET with this Id, I have the following response:
200
{
"name": "us-east1.11264560501473964275",
"metadata": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoProgress",
"annotationProgress": [
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:18:01.274877Z"
},
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:14:39.074505Z"
},
{
"inputUri": "/gccl_dd_01/Video1",
"progressPercent": 100,
"startTime": "2018-08-06T17:13:58.129978Z",
"updateTime": "2018-08-06T17:16:23.230536Z"
}
]
},
"done": true,
"response": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoResponse",
"annotationResults": [
{
"inputUri": "/gccl_dd_01/Video1",
"segmentLabelAnnotations": [
...
],
"shotLabelAnnotations": [
...
],
"shotAnnotations": [
...
]
}
]
}
}
The done parameter for the response is set to true, but it does not have any field containing the annotations for Explicit Content.
This issue seems to be occurring at random to my novice eyes. The APIs will return a response with all parameters on some occasions and be missing one on others. I am wondering if there is anything I am missing here or something on my end that is causing this?
I did some tests using just LABEL_DETECTION, just EXPLICIT_CONTENT_DETECTION and using the three of them.
As I am not using videos with explicit content, I don't see any specific field when adding just EXPLICIT_CONTENT_DETECTION:
{
"name": "europe-west1.462458490043912485",
"metadata": {
"#type": "type.googleapis.com/google.cloud.videointelligence.v1.AnnotateVideoProgress",
"annotationProgress": [
{
"inputUri": "/cloud-ml-sandbox/video/chicago.mp4",
"startTime": "2018-08-07T14:18:40.086713Z",
"updateTime": "2018-08-07T14:18:40.230351Z"
}
]
}
}
Can you share a specific video sample, the request.json used and two different outputs, please?

FHIR DSTU2: What is the correct way to represent an extension value as a collection?

I'm currently looking into creating a FHIR DSTU2 extension. I need the extension to return a collection of values. What is the correct way to represent this in FHIR DSTU2?
Should it be a list of extensions within an extension:
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.myextension.com/strengths",
"extension": [
{
"url": "http://www.myextension.com/strength",
"valueStrength": "5mg"
},
{
"url": "http://www.myextension.com/strength",
"valueStrength": "20mg"
}
]
}
],
}
Or should it be one extension with a collection on the value?
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.emis-online.com/strengths",
"valueStrengths": [
"5mg",
"20mg"
],
}
],
}
Thanks.
It would actually look like this:
"resource": {
"resourceType": "Medication",
"extension": [
{
"url": "http://www.myextension.com/strength",
"valueString": "5mg"
},
{
"url": "http://www.myextension.com/strength",
"valueString": "20mg"
}
]}
As well, it'd be better to use valueQuantity than valueString - to split the value and the unit.
That said, there's no reason to use an extension for drug strengths at all. Medication.product.ingredient.amount is strength - if the ingredient is an active ingredient. (I see that the resource doesn't currently allow distinguishing active from excipient ingredients, so I'd encourage raising a change request on that.)

Crossbar.io - Restrict user to subscribe to only two topics

I had seen in the Crossbar.io documentation, that we can set role to publish only to specific topic. But how can I set a role to publish exactly matching two topics rather than pattern based matching.
You can use a configuration like this (see Static Authorization in the docs):
"realms": [
{
"name": "realm1",
"roles": [
{
"name": "role1",
"permissions": [
{
"uri": "com.example.topic1",
"publish": true
},
{
"uri": "com.example.topic2",
"publish": true
}
]
}
]
}
]

Resources