(* Configuration for the server. This is a sample config only. *)

netplex {
  controller {
    max_level = "debug";    (* Log level *)
    logging {
      type = "stderr";    (* Log to stderr *)
    }
  };

  (* Now we describe the controller service. The two RPC programs
     Controller and Interface run in the same process, and can be reached
     over the same ports. The only difference is that Interface is the
     external interface while Controller is internally used.

     This service must only run once in the cluster.
  *)

  service {
    name = "sort";
    protocol {
      (* This section creates the external socket *)
      name = "Interface";
      address {
        type = "internet";
        bind = "0.0.0.0:2021";
      };
    };
    protocol {
      (* This section creates the internal socket *)
      name = "Controller";
      address {
        type = "container";  (* container-local socket *)
      };
    };
    processor {
      type = "sort";
      (* n_workers: This many workers are actually used. It must be ensured
           that this many worker processes are really started!
         max_depth: The depth of the sort_merge_tree. max_depth-1 is the
           number of consecutive merge operations.
      *)
      n_workers = 4;
      max_depth = 4;
    };
    workload_manager {
      (* This means there is only one process for the controller: *)
      type = "constant";
      jobs = 1
    };
  };


  (* The worker service. We create a static number of processes (which is
     best compatible with "container"-style sockets).
   *)

  service {
    name = "sort_worker";
    protocol {
      (* This section creates the socket *)
      name = "Worker";
      address {
        type = "container";
      };
    };
    processor {
      type = "sort_worker";
    };
    workload_manager {
      type = "constant";
      jobs = 4;    (* must be bigger than n_jobs *)
    };
  };
}
