-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/demrum 863 custom data module skeleton (#240)
* DEMRUM-863: adding MRUMCustomData (will be: SplunkCustomData) module skeleton * DEMRUM-863: fix swiftlint issues other than TODOs * DEMRUM-863: Update naming to SplunkCustomData
- Loading branch information
1 parent
5708128
commit e94afdc
Showing
10 changed files
with
350 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,8 @@ | ||
.DS_Store | ||
/.build | ||
/Packages | ||
xcuserdata/ | ||
DerivedData/ | ||
.swiftpm/configuration/registries.json | ||
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata | ||
.netrc |
66 changes: 66 additions & 0 deletions
66
SplunkCustomData/.swiftpm/xcode/xcshareddata/xcschemes/SplunkCustomData.xcscheme
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,66 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1520" | ||
version = "1.7"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "SplunkCustomData" | ||
BuildableName = "SplunkCustomData" | ||
BlueprintName = "SplunkCustomData" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
shouldAutocreateTestPlan = "YES"> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<MacroExpansion> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "SplunkCustomData" | ||
BuildableName = "SplunkCustomData" | ||
BlueprintName = "SplunkCustomData" | ||
ReferencedContainer = "container:"> | ||
</BuildableReference> | ||
</MacroExpansion> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
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,33 @@ | ||
// swift-tools-version: 5.9 | ||
|
||
import PackageDescription | ||
|
||
let package = Package( | ||
name: "SplunkCustomData", | ||
platforms: [ | ||
.iOS(.v13), | ||
.tvOS(.v13), | ||
.visionOS(.v1) | ||
], | ||
products: [ | ||
.library( | ||
name: "SplunkCustomData", | ||
targets: ["SplunkCustomData"] | ||
) | ||
], | ||
dependencies: [ | ||
.package(name: "SplunkSharedProtocols", path: "../SplunkSharedProtocols") | ||
], | ||
targets: [ | ||
.target( | ||
name: "SplunkCustomData", | ||
dependencies: [ | ||
"SplunkSharedProtocols" | ||
] | ||
), | ||
.testTarget( | ||
name: "SplunkCustomDataTests", | ||
dependencies: ["SplunkCustomData"] | ||
) | ||
] | ||
) |
64 changes: 64 additions & 0 deletions
64
SplunkCustomData/Sources/SplunkCustomData/CustomData+Module.swift
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,64 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
import Foundation | ||
import SplunkSharedProtocols | ||
|
||
// `Data` can be used as an event type that the module produces. | ||
extension Data: ModuleEventData {} | ||
|
||
// Struct `EventMetadataCustomData` describes event metadata. | ||
// This type must be unique in the module/agent space. | ||
extension EventMetadataCustomData: ModuleEventMetadata { | ||
public static func == (lhs: EventMetadataCustomData, rhs: EventMetadataCustomData) -> Bool { | ||
lhs.id == rhs.id | ||
} | ||
} | ||
|
||
// Defines CustomData conformance to `Module` protocol | ||
// and implements methods that are missing in the original `CustomData`. | ||
extension CustomData: Module { | ||
|
||
|
||
// MARK: - Module types | ||
|
||
public typealias Configuration = CustomDataConfiguration | ||
public typealias RemoteConfiguration = CustomDataRemoteConfiguration | ||
|
||
public typealias EventData = Data | ||
|
||
|
||
// MARK: - Module methods | ||
|
||
public func install(with configuration: (any ModuleConfiguration)?, remoteConfiguration: (any RemoteModuleConfiguration)?) { | ||
if let configuration = configuration as? CustomDataConfiguration { | ||
print("known configuration") | ||
print(configuration) | ||
} | ||
} | ||
|
||
|
||
// MARK: - Type transparency helpers | ||
|
||
public func deleteData(for metadata: any ModuleEventMetadata) { | ||
// TODO: Code TBD | ||
} | ||
|
||
public func onPublish(data: @escaping (EventMetadataCustomData, EventData) -> Void) { | ||
// TODO: Code TBD | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
SplunkCustomData/Sources/SplunkCustomData/CustomData.swift
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,46 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
import Foundation | ||
import SplunkSharedProtocols | ||
|
||
protocol CustomDataRepresentable: PropertyList {} | ||
|
||
public final class CustomData { | ||
|
||
|
||
// MARK: - Private properties | ||
|
||
private var config = CustomDataConfiguration(enabled: true) | ||
|
||
|
||
// MARK: - CustomData lifecycle | ||
|
||
public required init() {} // see install() in Module extension for startup tasks | ||
|
||
|
||
// MARK: - CustomData helper functions | ||
|
||
|
||
// MARK: - CustomData Reporting | ||
|
||
// This is a placeholder for temporary use only. Will be replaced by | ||
// real data population and output. | ||
private func reportCustom(data: CustomDataRepresentable) { | ||
print(String(describing: data)) | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
SplunkCustomData/Sources/SplunkCustomData/CustomDataConfiguration.swift
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,36 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
import Foundation | ||
import SplunkSharedProtocols | ||
|
||
public struct CustomDataConfiguration: ModuleConfiguration { | ||
|
||
|
||
// MARK: - Public | ||
|
||
public var enabled: Bool | ||
public var threshold: CFTimeInterval | ||
|
||
|
||
// MARK: init() | ||
|
||
public init(enabled: Bool, threshold: CFTimeInterval = 2.0) { | ||
self.enabled = enabled | ||
self.threshold = threshold | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
SplunkCustomData/Sources/SplunkCustomData/CustomDataRemoteConfiguration.swift
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,34 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
import Foundation | ||
import SplunkSharedProtocols | ||
|
||
public struct CustomDataRemoteConfiguration: RemoteModuleConfiguration { | ||
|
||
|
||
// MARK: - Public | ||
|
||
public var enabled: Bool | ||
|
||
|
||
// MARK: init() | ||
|
||
public init?(from data: Data) { | ||
enabled = true | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
SplunkCustomData/Sources/SplunkCustomData/EventMetadataCustomData.swift
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,31 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
import Foundation | ||
|
||
public struct EventMetadataCustomData { | ||
|
||
|
||
// MARK: - Public | ||
|
||
public var timestamp = Date() | ||
|
||
|
||
// MARK: - Internal | ||
|
||
let id: String | ||
} |
29 changes: 29 additions & 0 deletions
29
SplunkCustomData/Tests/SplunkCustomDataTests/SplunkCustomDataTests.swift
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,29 @@ | ||
// | ||
/* | ||
Copyright 2025 Splunk Inc. | ||
|
||
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. | ||
*/ | ||
|
||
@testable import SplunkCustomData | ||
import XCTest | ||
|
||
final class SplunkCustomDataTests: XCTestCase { | ||
func testExample() throws { | ||
// XCTest Documentation | ||
// https://developer.apple.com/documentation/xctest | ||
|
||
// Defining Test Cases and Test Methods | ||
// https://developer.apple.com/documentation/xctest/defining_test_cases_and_test_methods | ||
} | ||
} |