// Copyright 2025 The Drasi Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#![allow(unexpected_cfgs)]

//! No-op bootstrap provider for sources without bootstrap support

pub mod descriptor;

use anyhow::Result;
use async_trait::async_trait;
use log::info;

use drasi_lib::bootstrap::{
    BootstrapContext, BootstrapProvider, BootstrapRequest, BootstrapResult,
};
use drasi_lib::channels::BootstrapEventSender;

/// Bootstrap provider that returns no data
pub struct NoOpBootstrapProvider;

impl NoOpBootstrapProvider {
    /// Create a new no-op bootstrap provider
    pub fn new() -> Self {
        Self
    }

    /// Create a builder for NoOpBootstrapProvider
    pub fn builder() -> NoOpBootstrapProviderBuilder {
        NoOpBootstrapProviderBuilder::new()
    }
}

impl Default for NoOpBootstrapProvider {
    fn default() -> Self {
        Self::new()
    }
}

/// Builder for NoOpBootstrapProvider
///
/// This builder is provided for API consistency with other bootstrap providers,
/// though no configuration options are available since no-op returns no data.
pub struct NoOpBootstrapProviderBuilder;

impl NoOpBootstrapProviderBuilder {
    /// Create a new builder
    pub fn new() -> Self {
        Self
    }

    /// Build the NoOpBootstrapProvider
    pub fn build(self) -> NoOpBootstrapProvider {
        NoOpBootstrapProvider
    }
}

impl Default for NoOpBootstrapProviderBuilder {
    fn default() -> Self {
        Self::new()
    }
}

#[async_trait]
impl BootstrapProvider for NoOpBootstrapProvider {
    async fn bootstrap(
        &self,
        request: BootstrapRequest,
        _context: &BootstrapContext,
        _event_tx: BootstrapEventSender,
        _settings: Option<&drasi_lib::config::SourceSubscriptionSettings>,
    ) -> Result<BootstrapResult> {
        info!(
            "No-op bootstrap for query {}: returning no data",
            request.query_id
        );
        Ok(BootstrapResult::default())
    }
}

// Core plugin — registered statically by the server, not exported for dynamic loading.
