load("@fbcode_macros//build_defs:cpp_library.bzl", "cpp_library")

oncall("fbcode_entropy_wardens_folly")

cpp_library(
    name = "channel",
    exported_deps = [
        ":async_socket_handler",  # @manual
        ":event_base_handler",  # @manual
        ":file_region",  # @manual
        ":handler",  # @manual
        ":handler_context",  # @manual
        ":output_buffering_handler",  # @manual
        ":pipeline",  # @manual
        ":static_pipeline",  # @manual
    ],
)

# Main Rules

cpp_library(
    name = "async_socket_handler",
    headers = ["AsyncSocketHandler.h"],
    exported_deps = [
        ":handler",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/io/async:async_socket",
        "//folly/io/async:event_base_manager",
    ],
)

cpp_library(
    name = "event_base_handler",
    headers = ["EventBaseHandler.h"],
    exported_deps = [
        ":handler",
        "//folly/futures:core",
    ],
)

cpp_library(
    name = "file_region",
    srcs = ["FileRegion.cpp"],
    headers = ["FileRegion.h"],
    exported_deps = [
        "//folly:singleton",
        "//folly/executors:io_thread_pool_executor",
        "//folly/futures:core",
        "//folly/io/async:async_base",
        "//folly/io/async:async_socket",
        "//folly/io/async:async_transport",
    ],
)

cpp_library(
    name = "handler",
    headers = ["Handler.h"],
    exported_deps = [
        ":pipeline",
        "//folly/futures:core",
        "//folly/io:iobuf",
    ],
)

cpp_library(
    name = "handler_context",
    headers = [
        "HandlerContext.h",
        "HandlerContext-inl.h",
    ],
    exported_deps = [
        "//folly:exception_wrapper",
        "//folly:format",
        "//folly/futures:core",
        "//folly/io/async:async_transport",
    ],
)

cpp_library(
    name = "output_buffering_handler",
    headers = ["OutputBufferingHandler.h"],
    exported_deps = [
        ":handler",
        "//folly/futures:shared_promise",
        "//folly/io:iobuf",
        "//folly/io/async:async_base",
        "//folly/io/async:event_base_manager",
    ],
)

cpp_library(
    name = "pipeline",
    srcs = ["Pipeline.cpp"],
    headers = [
        "Pipeline.h",
        "Pipeline-inl.h",
    ],
    exported_deps = [
        ":handler_context",
        "//folly:exception_wrapper",
        "//folly:memory",
        "//folly:optional",
        "//folly:unit",
        "//folly/futures:core",
        "//folly/io:iobuf",
        "//folly/io/async:async_transport",
        "//folly/io/async:async_udp_socket",
        "//folly/io/async:delayed_destruction",
        "//folly/io/async:request_context",
        "//wangle/acceptor:secure_transport_type",
        "//wangle/acceptor:transport_info",
    ],
    exported_external_deps = [
        "glog",
    ],
)

cpp_library(
    name = "static_pipeline",
    headers = ["StaticPipeline.h"],
    exported_deps = [
        ":pipeline",
    ],
)
