-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: move sidecar interface to separate file
- Loading branch information
Showing
3 changed files
with
121 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
// Copyright 2021-Present Datadog, Inc. https://www.datadoghq.com/ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::interface::{SessionConfig, SidecarAction}; | ||
use crate::service::{ | ||
InstanceId, QueueId, RequestIdentification, RequestIdentifier, RuntimeMetadata, | ||
SerializedTracerHeaderTags, | ||
}; | ||
use anyhow::Result; | ||
use datadog_ipc::platform::ShmHandle; | ||
use datadog_ipc::tarpc; | ||
|
||
/// The `SidecarInterface` trait defines the necessary methods for the sidecar service. | ||
/// | ||
/// These methods include operations such as enqueueing actions, registering services, setting | ||
/// session configurations, and sending traces. | ||
#[datadog_sidecar_macros::extract_request_id] | ||
#[datadog_ipc_macros::impl_transfer_handles] | ||
#[tarpc::service] | ||
pub trait SidecarInterface { | ||
/// Enqueues a list of actions to be performed. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `instance_id` - The ID of the instance. | ||
/// * `queue_id` - The unique identifier for the action in the queue. | ||
/// * `actions` - The action type being enqueued. | ||
async fn enqueue_actions( | ||
instance_id: InstanceId, | ||
queue_id: QueueId, | ||
actions: Vec<SidecarAction>, | ||
); | ||
|
||
/// Registers a service and flushes any queued actions. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `instance_id` - The ID of the instance. | ||
/// * `queue_id` - The unique identifier for the action in the queue. | ||
/// * `meta` - The metadata of the runtime. | ||
/// * `service_name` - The name of the service. | ||
/// * `env_name` - The name of the environment. | ||
async fn register_service_and_flush_queued_actions( | ||
instance_id: InstanceId, | ||
queue_id: QueueId, | ||
meta: RuntimeMetadata, | ||
service_name: String, | ||
env_name: String, | ||
); | ||
|
||
/// Sets the configuration for a session. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `session_id` - The ID of the session. | ||
/// * `config` - The configuration to be set. | ||
async fn set_session_config(session_id: String, config: SessionConfig); | ||
|
||
/// Shuts down a runtime. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `instance_id` - The ID of the instance. | ||
async fn shutdown_runtime(instance_id: InstanceId); | ||
|
||
/// Shuts down a session. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `session_id` - The ID of the session. | ||
async fn shutdown_session(session_id: String); | ||
|
||
/// Sends a trace via shared memory. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `instance_id` - The ID of the instance. | ||
/// * `handle` - The handle to the shared memory. | ||
/// * `headers` - The serialized headers from the tracer. | ||
async fn send_trace_v04_shm( | ||
instance_id: InstanceId, | ||
#[SerializedHandle] handle: ShmHandle, | ||
headers: SerializedTracerHeaderTags, | ||
); | ||
|
||
/// Sends a trace as bytes. | ||
/// | ||
/// # Arguments | ||
/// | ||
/// * `instance_id` - The ID of the instance. | ||
/// * `data` - The trace data serialized as bytes. | ||
/// * `headers` - The serialized headers from the tracer. | ||
async fn send_trace_v04_bytes( | ||
instance_id: InstanceId, | ||
data: Vec<u8>, | ||
headers: SerializedTracerHeaderTags, | ||
); | ||
|
||
/// Sends a ping to the service. | ||
async fn ping(); | ||
|
||
/// Dumps the current state of the service. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A string representation of the current state of the service. | ||
async fn dump() -> String; | ||
|
||
/// Retrieves the current statistics of the service. | ||
/// | ||
/// # Returns | ||
/// | ||
/// A string representation of the current statistics of the service. | ||
async fn stats() -> String; | ||
} |