是否可以在没有HTTP请求的情况下访问GAE数据存储?

huangapple go评论88阅读模式
英文:

Is it possible to access GAE datastore without an http request?

问题

在不使用http请求的情况下,是否可以访问GAE数据存储?我希望能够在没有访问app engine上下文的独立线程中访问数据存储。这种可能吗?还是我应该尝试找到一种解决方法?顺便说一下,我使用的语言是Go...

编辑:更多信息
我无法将所有的app engine上下文传递到所需的级别,因为我正在构建一个具有多个线程的聊天服务器。一旦启动了主端口监听线程,并且有一个上下文的实例,它将在整个线程的持续时间内保持该上下文。然而,在该线程启动之后,可能会有许多其他连接到服务器的连接,所有这些连接都无法通过上下文传递,因为端口监听器已经启动。我需要将上下文传递到最后是因为我需要能够在客户端读取处理程序中记录消息。提前感谢。

英文:

Is it possible to access GAE datastore without making an appengine context out of a http request?
I want to be able to access the datastore in separate threads that do not have access to the app engine context. is this possible? or should i try to find a work around?
the language im working in is Go btw...

EDIT: More info
The reason i can't use pass all the appengine contexts down to the level needed is because im building a chat server with multiple threads. Once the main port listening thread is started, with the one instance of a context, it keeps that context around for the duration of the thread. However, after that thread starts, there can be many more connections to the server all of which cant pass through a context because the port listener is already started. The reason i need the context passed all the way through is because i need to be able to log messages in the client read handler.
Thanks in advance

答案1

得分: 3

我不确定这是否是你要找的,但GAE提供了一个远程API,它使你能够与你的服务进行交互。我确定它提供了Python和Java版本。

英文:

I am not really sure if this is what you are looking for, but GAE provides a remote api which gives you the ability to interact with your service. I am sure its provided for Python and Java versions.

答案2

得分: 1

我认为你需要一个appengine.Context(因此需要请求)来访问任何数据存储。幸运的是,将请求传递给需要它的代码部分应该很容易。

我不确定appengine_internal如何处理上下文,但上下文本身可以根据需要来回传递。如果你认为这对你不起作用,也许一个代码示例会是下一步的好选择?

英文:

I think you'll need an appengine.Context (and therefore the request) for any datastore access. Fortunately the request should be easy enough to pass to whatever part of your code requires it.

I'm not sure what appengine_internal does with the context, but the context itself can be passed back and forth as required. Maybe a code example would be a good next step if you don't think this will work for you?

huangapple
  • 本文由 发表于 2013年1月22日 15:14:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/14453367.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定