diff --git a/OpenTelemetry.sln b/OpenTelemetry.sln index b4d533b00..62972e8e5 100644 --- a/OpenTelemetry.sln +++ b/OpenTelemetry.sln @@ -202,6 +202,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenTelemetry.Exporter.InMe EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "extending-the-sdk", "docs\logs\extending-the-sdk\extending-the-sdk.csproj", "{13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenTelemetry.Shared", "src\OpenTelemetry.Shared\OpenTelemetry.Shared.csproj", "{1E504265-1E32-4C61-8CC5-8FA373E16699}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -396,6 +398,10 @@ Global {13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Debug|Any CPU.Build.0 = Debug|Any CPU {13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Release|Any CPU.ActiveCfg = Release|Any CPU {13C10C9A-07E8-43EB-91F5-C2B116FBE0FC}.Release|Any CPU.Build.0 = Release|Any CPU + {1E504265-1E32-4C61-8CC5-8FA373E16699}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1E504265-1E32-4C61-8CC5-8FA373E16699}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1E504265-1E32-4C61-8CC5-8FA373E16699}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1E504265-1E32-4C61-8CC5-8FA373E16699}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/OpenTelemetry.Shared/IPersistentBlob.cs b/src/OpenTelemetry.Shared/IPersistentBlob.cs new file mode 100644 index 000000000..b77ba9324 --- /dev/null +++ b/src/OpenTelemetry.Shared/IPersistentBlob.cs @@ -0,0 +1,62 @@ +// +// Copyright The OpenTelemetry 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. +// + +namespace OpenTelemetry.Shared +{ + /// + /// API to Read, Write and Delete a blob. + /// + public interface IPersistentBlob + { + /// + /// Read content of a blob from storage. + /// + /// + /// Blob content. + /// + public byte[] Read(); + + /// + /// Write a blob content to storage. + /// + /// + /// Buffer to write to storage. + /// + /// + /// Lease period in milliseconds. + /// + /// + /// A blob if there is an available one, or null if there is no blob available. + /// + public IPersistentBlob Write(byte[] buffer, int leasePeriodMilliseconds = 0); + + /// + /// Create and manage a lease on the blob. + /// + /// + /// Lease period in milliseconds. + /// + /// + /// A blob if there is an available one, or null if there is no blob available. + /// + public IPersistentBlob Lease(int leasePeriodMilliseconds); + + /// + /// Attempt to delete the blob. + /// + public void Delete(); + } +} diff --git a/src/OpenTelemetry.Shared/IPersistentStorage.cs b/src/OpenTelemetry.Shared/IPersistentStorage.cs new file mode 100644 index 000000000..3514f7dd3 --- /dev/null +++ b/src/OpenTelemetry.Shared/IPersistentStorage.cs @@ -0,0 +1,57 @@ +// +// Copyright The OpenTelemetry 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. +// + +using System.Collections.Generic; + +namespace OpenTelemetry.Shared +{ + /// + /// Persistent storage API. + /// + public interface IPersistentStorage + { + /// + /// Read a sequence of blobs from storage. + /// + /// + /// Sequence of blobs from storage. + /// + public IEnumerable GetBlobs(); + + /// + /// Attempt to get a blob from storage. + /// This function never throws. + /// + /// + /// A blob if there is an available one, or null if there is no blob available. + /// + IPersistentBlob GetBlob(); + + /// + /// Create a new blob with the provided data. + /// + /// + /// Blob content. + /// + /// + /// Lease period in milliseconds. + /// + /// + /// A blob if there is an available one, or null if there is no blob available. + /// + public IPersistentBlob CreateBlob(byte[] buffer, int leasePeriodMilliseconds = 0); + } +} diff --git a/src/OpenTelemetry.Shared/OpenTelemetry.Shared.csproj b/src/OpenTelemetry.Shared/OpenTelemetry.Shared.csproj new file mode 100644 index 000000000..6a40b0901 --- /dev/null +++ b/src/OpenTelemetry.Shared/OpenTelemetry.Shared.csproj @@ -0,0 +1,13 @@ + + + + net452;net46;net461;netstandard2.0 + Shared project for OpenTelemetry .NET + $(PackageTags);Shared + + + + $(NoWarn),1591 + + +