asanka88 commented on code in PR #1: URL: https://github.com/apache/synapse-go/pull/1#discussion_r1906374389
########## internal/app/synapse/synapse.go: ########## @@ -0,0 +1,50 @@ +/* +Copyright 2025 The Synapse 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 synapse + +import ( + "net/http" + "runtime" + "time" + + "github.com/apache/synapse-go/internal/pkg/artifacts" + "github.com/apache/synapse-go/internal/pkg/consolelogger" + "github.com/apache/synapse-go/internal/pkg/deployer" + "github.com/apache/synapse-go/internal/pkg/dispatcher" +) + +func Run() error { Review Comment: shall we use cobra to handle the cli part of this ? and viper to handle the config file. @GDLMadushanka ########## internal/pkg/artifacts/callMediator.go: ########## @@ -0,0 +1,83 @@ +/* +Copyright 2025 The Synapse 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 artifacts + +import ( + "bytes" + "io" + "net/http" + "strings" + "time" + + "github.com/apache/synapse-go/internal/pkg/consolelogger" + "github.com/apache/synapse-go/internal/pkg/synapsecontext" +) + +type CallMediator struct { + Endpoint CallEndpoint `xml:"endpoint"` + LineNo int + FileName string +} + +type CallEndpoint struct { + Key string `xml:"key,attr"` +} + Review Comment: since http client is thread safe it is fine to share. but if we use one per mediator instance each mediator configs can decide the Transport properties. @GDLMadushanka ########## internal/pkg/artifacts/api.go: ########## @@ -0,0 +1,54 @@ +/* +Copyright 2025 The Synapse 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 artifacts + +import ( + "net/http" + + "github.com/apache/synapse-go/internal/pkg/synapsecontext" +) + +type Resource struct { + Methods string `xml:"methods,attr"` + URITemplate string `xml:"uri-template,attr"` + InSequence Sequence `xml:"inSequence"` + FaultSequence Sequence `xml:"faultSequence"` +} + +type API struct { + Context string `xml:"context,attr"` + Name string `xml:"name,attr"` + Resources []Resource `xml:"resource"` + FileName string +} + +func (resource *Resource) DispatchResource(w http.ResponseWriter, request *http.Request) { + // Read transport headers + var headers = make(map[string]string) + for name, values := range request.Header { + headers[name] = values[0] + } + + // Creating the mssage context + var context = synapsecontext.SynapseContext{ Review Comment: we should use go context and we can make synapse context part of it . wdyt ? @GDLMadushanka -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: dev-unsubscr...@synapse.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@synapse.apache.org For additional commands, e-mail: dev-h...@synapse.apache.org