-
Notifications
You must be signed in to change notification settings - Fork 15
Changing priorities of modules
There is a short and long version #Short version
- List modules: Run
utils/lodspk.sh list modules
- Position the desired module (e.g.,
type
) in a specific position: Runutils/lodspk.sh enable module type 1
- List modules again to confirm that changes occurred: Run
utils/lodspk.sh list modules
#Long version LODSPeaKr runs one module per URI request (see Modules for more info). By default, the modules available are executed in the following order:
- Static
- Service
- Type
An example of when you may want to change it: Imagine you have URIs following the following convention
http://example.org/id/thing_1
http://example.org/id/thing_2
http://example.org/id/thing_2/subthing_1
http://example.org/id/thing_2/subthing_2
http://example.org/id/thing_3
Now, you want to mint http://example.org/id
to be the document that returns a list of resources based on a certain SPARQL query. The way of doing this is to create a service called id
by running
utils/lodspk.sh create service id
Now you can start working on your query to retrieve the right resources. But wait! now URIs like http://example.org/id/thing_1
won't get served, since LODSPeaKr will interpret that you are requesting http://example.org/id
using thing_1
as a parameter. This happens because by default the service
module has priority over type
module.
First, go to the LODSPeaKr directory and run
utils/lodspk.sh list modules
You should see something like
0) static
1) service
2) type
this indicates that when receiving a request, LODSPeaKr will first ask to the static
module if it should deal with such request. If not, it will ask the service
module the same. In our case, the service
module will recognize the pattern id/*
in the URI and given that it exist a component called id
it will accept the request. Since service
module will take care of the request, LODSPeaKr will never ask to the type
module, which is the one that should actually serve that URI.
In order to change the priorities you can run
$ utils/lodspk.sh enable module type 1
Module type enabled successfully
This tells LODSPeaKr that module type
should be positioned in place 1. Every other module will be displaced one position. Listing the modules again should reflect the changes
utils/lodspk.sh list modules
0) static
1) type
2) service
Now when http://example.org/id/thing_1
is requested, LODSPeaKr will ask the static
module and then to the type
module. Since this URI exist in the triple store, type
module will be served it based on whatever component is available.