

#ifndef FUNCTION_BIDDING_FUNCTION_INTERFACE_H_H_
#define FUNCTION_BIDDING_FUNCTION_INTERFACE_H_H_

#include "absl/status/statusor.h"
#include "proto/bidding_function.pb.h"

namespace aviary {
namespace function {

struct FunctionOptions {
  // Whether to flatten function arguments from the fields of the input
  // object.
  //
  // When false, input message is converted to a JSON object, which is
  // provided as a single argument to the function.
  //
  // When true, each field in the input message  converted into a JSON
  // value becomes an individual argument to the function in the order of
  // declaration in the protocol buffer.
  bool flatten_function_arguments = false;
};

// JavaScript function that executes the sandboxed bidding and auction logic.
template <typename Input, typename Output>
class BiddingFunctionInterface {
 public:
  // Invokes the function for as many `bidding_function_inputs` as are provided.
  // Returns a vector of resulting bid price CPMs in the order of invocation.
  // If one invocation fails, no bid prices are returned, and the status of the
  // first failing invocation is returned.
  //
  // Blocks until all the outputs can be returned, or until a failure has been
  // detected.
  virtual absl::StatusOr<std::vector<Output>> BatchInvoke(
      const std::vector<Input>& bidding_function_inputs) const = 0;
};
}  // namespace function
}  // namespace aviary
#endif  // FUNCTION_BIDDING_FUNCTION_INTERFACE_H_H_
