[#86787] [Ruby trunk Feature#14723] [WIP] sleepy GC — ko1@...

Issue #14723 has been updated by ko1 (Koichi Sasada).

13 messages 2018/05/01
[#86790] Re: [Ruby trunk Feature#14723] [WIP] sleepy GC — Eric Wong <normalperson@...> 2018/05/01

ko1@atdot.net wrote:

[#87095] [Ruby trunk Feature#14767] [PATCH] gc.c: use monotonic counters for objspace_malloc_increase — ko1@...

Issue #14767 has been updated by ko1 (Koichi Sasada).

9 messages 2018/05/17

[ruby-core:87139] [Ruby trunk Feature#14771] Add method to create DNS resource from data string

From: samuel@...
Date: 2018-05-17 12:36:34 UTC
List: ruby-core #87139
Issue #14771 has been updated by ioquatix (Samuel Williams).


The suggested code should be (missing `resource =`):

```
        if klass = Resolv::DNS::Resource.get_class(answer["type"], resource_class::ClassValue)
          resource = klass.create(answer["data"])
        end
```

----------------------------------------
Feature #14771: Add method to create DNS resource from data string
https://bugs.ruby-lang.org/issues/14771#change-72130

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
I recently played around with DNS over HTTPS.

I found that it's a little bit tricky to generate the appropriate resource using the Resolv::DNS::Resource hierarchy.

Here is what my code ended up:

```
        if klass = Resolv::DNS::Resource.get_class(answer["type"], resource_class::ClassValue)
          if klass < Resolv::DNS::Resource::DomainName
            resource = klass.new(Resolv::DNS::Name.create(answer["data"]))
          else
            resource = klass.new(answer["data"])
          end
```

It would be nice to have a simpler interface, e.g.

```
        if klass = Resolv::DNS::Resource.get_class(answer["type"], resource_class::ClassValue)
          klass.create(answer["data"])
        end
```

In this case, the `Resource#create` method would take a data string and convert it to a name if required.

The base resource class could just have `alias create new`, while the `DomainName` class could have:

```
def create(data)
  self.new(Name.create(data))
end
```

Or something like that.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next