-
Notifications
You must be signed in to change notification settings - Fork 154
Ports command line argument handling for proxy and handler to Rust #48232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 15 commits
Commits
Show all changes
58 commits
Select commit
Hold shift + click to select a range
51e93a8
Added boost path for Mac Silicon Brew installations
serra-fastly 8dd26f2
Adds C compatible struct and conversion function
serra-fastly 1a9c8c3
Updates call_c_main call to include new arguments
serra-fastly a74311f
Changes into_c_struct to into_osstring_vec
serra-fastly c56ec9d
Updates args to work with existing ffi functions and modules
serra-fastly 7326fb7
Adds unit test for Rust handler args
serra-fastly 6df9c3e
Adds loading settings from cli and unit testing
serra-fastly 3f4f54b
changed name of test fxn
serra-fastly 1cf7cee
Adds new arg vars to test mod
serra-fastly a8d5978
Adds ArgsData to proxy
serra-fastly 2ee4081
Updated args values in runner
serra-fastly 8f18304
Adds proxy argument handling unit tests
serra-fastly 5b24d05
Resolves clippy warnings and removes reduntant comments
serra-fastly 153588a
Resolves linter issues
serra-fastly 63d6109
Resolves clippy warning
serra-fastly ce7de89
Removes stray debuggging statement
serra-fastly db0624d
Adds new C++ compatible struct for bindgen compatibility for CCliArgs
serra-fastly 3d0d861
Updates run functions in proxy and handler to accept new CCliArgsFfi
serra-fastly 4c22bb8
Changes routes from string list to array of strings and removes Osst…
serra-fastly 76640e7
Updates Settings to use ArgsData
serra-fastly ee677db
Refactors ArgsData to accept CCliArgsFfi instead of argc/argv
serra-fastly aa1c279
Integrates FFI argument handling into proxy and handler components
serra-fastly 13dc80a
Restores old Settings constructor for backwards compatibility
serra-fastly 73bcf06
Fixes warning about int vs unsigned int
serra-fastly 66ffacb
Changes routes to return empty array instead of nullptr when empty
serra-fastly dda5e95
Refactors handler and proxy tests to use new FFI structs
serra-fastly 8981999
Resolves circular dependency issues in ArgsData and Settings
serra-fastly 7b905d7
Renames ArgsData in runner to RunnerArgsData
serra-fastly 999c09d
Integrates FFI structs into the module calls for handler and proxy
serra-fastly e5e1927
Fix for FFI config_file to use proper valid default instead of empty …
serra-fastly bbde02b
Fixes incorrect empty str check and adds new getters in Settings
serra-fastly 7bc65c3
Adds new Settings tests
serra-fastly 8bfd1dd
Merge remote-tracking branch 'origin' into serra/rust-arg-handler
serra-fastly c7b3bcc
Replaces run_serial with run_cpp for tests, fixes a linking bug, remo…
serra-fastly 0649f0c
Calls fromUtf8 on arguments for better parsing
serra-fastly 3f1dc5b
Deletes unnecessary equivalency operator
serra-fastly ad3cd49
Splits and refactors CliArgs into individual structs for handler and …
serra-fastly 5142efb
Removes getters/setters from CliArgsFfi and makes fields public instead
serra-fastly 88b92ca
Removes unnecessary fields and renames Ffi structs to resolve duplica…
serra-fastly 0161b9a
Removes unncessary IntoIterator
serra-fastly 1890fa2
Removes unnecessary storage of routeCount in ProxyArgsData
serra-fastly bae6603
Adds safety documentation FFI destroy functions, per clippy
serra-fastly 8e80e75
Adds destruction of args at end of execution
serra-fastly a561fa2
Refactors iteration from i..num to enumerate, per clippy
serra-fastly dbf51be
Moves destroy and to_ffi fxns out of the ffi mod
serra-fastly d45330d
Reverts arg styles
serra-fastly 515d64a
Removes Ffi suffix from args struct
serra-fastly f5b2f5d
Removes unnecessary import
serra-fastly 7a64c9c
Removes qapp from testing
serra-fastly c0810ce
Removes log.txt and adds it to gitignore
serra-fastly bb5eb4d
Moves handler and proxy cliargs into respective folders
serra-fastly c175539
Removes extra whitespace line
serra-fastly fa77189
Changed pushpin-handler test back to false
serra-fastly c279256
Creates test log file in log dir and removes log.txt from gitignore
serra-fastly 09d4edc
Changes routes arg to route in proxy
serra-fastly 2fbe712
Changes log file failure from throws exception to exit
serra-fastly f32d28f
Relocates log set up to run and adds unique log filename to tests
serra-fastly a84eef1
Changes error handling exit(1) to return 1
serra-fastly File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 hidden or 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 hidden or 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
jkarneges marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
Empty file.
This file contains hidden or 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 hidden or 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 hidden or 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,88 @@ | ||
| /* | ||
| * Copyright (C) 2015-2022 Fanout, Inc. | ||
| * Copyright (C) 2024-2025 Fastly, Inc. | ||
| * | ||
| * This file is part of Pushpin. | ||
| * | ||
| * $FANOUT_BEGIN_LICENSE:APACHE2$ | ||
| * | ||
| * 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. | ||
| * | ||
| * $FANOUT_END_LICENSE$ | ||
| */ | ||
|
|
||
| #include "argsdata.h" | ||
| #include "settings.h" | ||
| #include "config.h" | ||
| #include "log.h" | ||
| #include <QCoreApplication> | ||
| #include <QFile> | ||
|
|
||
|
|
||
| Settings ArgsData::loadIntoSettings() | ||
| { | ||
| Settings settings(configFile); | ||
|
|
||
| if(!ipcPrefix.isEmpty()) | ||
| settings.setIpcPrefix(ipcPrefix); | ||
|
|
||
| if(portOffset != -1) | ||
| settings.setPortOffset(portOffset); | ||
|
|
||
| return settings; | ||
| } | ||
|
|
||
| ArgsData::ArgsData(QStringList &extArgs) | ||
| { | ||
| if(extArgs.isEmpty()) | ||
| { | ||
| log_error("Error processing arguments. Use --help for usage."); | ||
| throw std::exception(); | ||
| } | ||
|
|
||
| configFile = extArgs[0]; | ||
| logFile = !extArgs[1].isEmpty() ? extArgs[1] : QString(); | ||
| logLevel = extArgs[2].toInt(); | ||
| ipcPrefix = extArgs[3]; | ||
| portOffset = !extArgs[4].isEmpty() ? extArgs[4].toInt() : -1; | ||
| routeLines = extArgs[5].isEmpty() ? QStringList() : extArgs[5].split(','); | ||
| quietCheck = extArgs[6] == "true" ? true : false; | ||
|
|
||
| // Set the log level | ||
| if(logLevel != -1) | ||
| log_setOutputLevel(logLevel); | ||
| else | ||
| log_setOutputLevel(LOG_LEVEL_INFO); | ||
|
|
||
| // Set the log file if specified | ||
| if(!logFile.isEmpty()) | ||
| { | ||
| if(!log_setFile(logFile)) | ||
| { | ||
| log_error("failed to open log file: %s", qPrintable(logFile)); | ||
| throw std::exception(); | ||
| } | ||
| } | ||
|
|
||
| log_debug("starting..."); | ||
|
|
||
| // QSettings doesn't inform us if the config file can't be opened, so do that ourselves | ||
| { | ||
| QFile file(configFile); | ||
| if(!file.open(QIODevice::ReadOnly)) | ||
| { | ||
| log_error("failed to open %s", qPrintable(configFile)); | ||
| throw std::exception(); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.