Skip to content

Commit

Permalink
Start libevent implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
rnburn authored and Johannes Tax committed Jul 7, 2020
1 parent 73d9d9d commit 9685fb2
Show file tree
Hide file tree
Showing 6 changed files with 77 additions and 4 deletions.
13 changes: 11 additions & 2 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,19 @@ new_local_repository(
path = "third_party/opentelemetry-proto",
)

http_archive(
name = "bazel_skylib",
urls = [
"https://github.com/bazelbuild/bazel-skylib/archive/1.0.2.zip",
],
sha256 = "64ad2728ccdd2044216e4cec7815918b7bb3bb28c95b7e9d951f9d4eccb07625",
strip_prefix = "bazel-skylib-1.0.2",
)

http_archive(
name = "rules_foreign_cc",
strip_prefix = "rules_foreign_cc-ed3db61a55c13da311d875460938c42ee8bbc2a5",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/ed3db61a55c13da311d875460938c42ee8bbc2a5.zip",
strip_prefix = "rules_foreign_cc-456425521973736ef346d93d3d6ba07d807047df",
url = "https://github.com/bazelbuild/rules_foreign_cc/archive/456425521973736ef346d93d3d6ba07d807047df.zip",
)

load("@rules_foreign_cc//:workspace_definitions.bzl", "rules_foreign_cc_dependencies")
Expand Down
3 changes: 3 additions & 0 deletions sdk/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@ cc_library(
name = "headers",
hdrs = glob(["include/**/*.h"]),
strip_include_prefix = "include",
deps = [
"//api",
],
)
2 changes: 0 additions & 2 deletions sdk/include/opentelemetry/sdk/common/file_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk {
namespace common {
#ifdef _WIN32
using FileDescriptor = intptr_t;
#else
using FileDescriptor = int;
#endif
} // namespace common
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
27 changes: 27 additions & 0 deletions sdk/src/event/libevent/BUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2020, 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.

package(default_visibility = ["//visibility:public"])

cc_library(
name = "libevent",
srcs = glob(["**/*.cc"]),
hdrs = glob(["**/*.h"]),
include_prefix = "src/event/libevent",
deps = [
"//sdk:headers",
"@com_github_libevent_libevent//:libevent",
],
)

11 changes: 11 additions & 0 deletions sdk/src/event/libevent/libevent_dispatcher.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#include "src/event/libevent/libevent_dispatcher.h"

#include "event2/event.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace event {
} // namespace event
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE
25 changes: 25 additions & 0 deletions sdk/src/event/libevent/libevent_dispatcher.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#pragma once

#include "opentelemetry/sdk/event/dispatcher.h"
#include "opentelemetry/version.h"

OPENTELEMETRY_BEGIN_NAMESPACE
namespace sdk
{
namespace event {
class LibeventDispatcher final : public Dispatcher {
public:
// Dispatcher
std::unique_ptr<FileEvent> CreateFileEvent(FileDescriptor file_descriptor,
FileReadyCallback callback,
uint32_t events) noexcept override;

std::unique_ptr<Timer> CreateTimer(TimerCallback callback) noexcept override;

void Exit() noexcept override;

void Run() noexcept override;
};
} // namespace event
} // namespace sdk
OPENTELEMETRY_END_NAMESPACE

0 comments on commit 9685fb2

Please sign in to comment.