Working with Http services


Vyne will connect to Http / RESTful services to fetch data as part of executing a query.

The @HttpOperation annotation

Services can provide operations annotation @HttpOperation.

service MovieService {
   @HttpOperation(method = "POST" , url = "http://localhost:9981/films/streamingServices")
   operation listActorsForMovie( @RequestBody request : MovieRequest ) : StreamingProvider

   // PathVariables can be inferred.  Use the name of the type
   @HttpOperation(method = "GET" , url = "http://localhost:9985/reviews/{com.acme.FilmId}")
   operation getReview(  filmId : com.acme.FilmId ) : FilmReview
}

Request Body

In the list of parameters for the operation, the request body (if applicable) should contain a @RequestBody annotation.

eg:

@HttpOperation(method = "POST" , url = "http://localhost:9981/films/streamingServices")
operation listActorsForMovie( @RequestBody request : MovieRequest ) : StreamingProvider

Path variables

Path variables are interpolated in the request string automatically. Use the fully qualified type name as a placeholder in the path variable:

eg:

// PathVariables can be inferred.  Use the name of the type
@HttpOperation(method = "GET" , url = "http://localhost:9985/reviews/{com.acme.FilmId}")
operation getReview(  filmId : com.acme.FilmId ) : FilmReview

Resolving urls and service names

Service names can be templated, and resolved at runtime - either through a service discovery container (such as Netflix Eureka or Hashicorp Consul), or through a configuration file.

Regardless of which method you're using, service names are first checked against configured hosts, before attempting DNS resolution.

For example:

@HttpOperation(method = "GET" , url = "http://films-service/reviews/{com.acme.FilmId}")
operation getReview(  filmId : com.acme.FilmId ) : FilmReview

In the above example, Vyne will check the Service Discovery provider (if configured), and the services.conf config file for a service named films-service. If present, the actual host name is swapped out before the call is initiated.

Resolving services using a config file (default)

By default, Vyne uses a config file to resolve host names. This is used for both networking between Vyne components, and resolving your own HTTP services.

By default, Vyne writes a config file containing default service names for it's own components at config/services.conf on startup. You can edit this file to provide addresses of your own services you wish to resolve.

services {
    // Vyne's own components, written by default
    analytics-server {
        url="http://vyne-analytics-server"
    }
    cask-server {
        url="http://cask"
    }
    pipeline-runner {
        url="http://vyne-pipeline-runner"
    }
    query-server {
        url="http://vyne"
    }
    schema-server {
      url="http://vyne-schema-server"
      rsocket-port=7655
    }

     // Append your own service URLs here.
    films-service {
      url="http://localhost:8080"
    }
}

You must restart Vyne's query engine for these changes to take effect.

See /deployment/deploying-vyne/#networking-between-components for more details on configuring the services.conf file`

Working with a Service Discovery container

See [/deployment/deploying-vyne/#service-discovery-with-eureka](Working with Eureka) for more details.